/* إخفاء شريط التمرير */
::-webkit-scrollbar { display: none; }
html { -ms-overflow-style: none; scrollbar-width: none; }

:root {
    --color-yellow-light: #fde047;
    --color-yellow-dark: #f59e0b;
    --color-red-light: #f87171;
    --color-red-dark: #dc2626;
    --color-blue-light: #60a5fa;
    --color-blue-dark: #2563eb;
    --color-green-light: #4ade80;
    --color-green-dark: #16a34a;
    --color-purple-light: #c084fc;
    --color-purple-dark: #9333ea;
}

body {
    font-family: 'AAGalaxy', sans-serif;
    background: radial-gradient(ellipse at center, #1e293b 0%, #0f172a 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
    color: #e2e8f0; 
    position: relative;
    overflow-x: hidden; 
    padding: 1rem;
}
.game-container {
    background-color: #1e293b; 
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); 
    width: 100%;
    max-width: 1200px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem; 
    animation: fadeIn 1s ease-in-out;
    border: 1px solid #334155; 
    color: #e2e8f0;
    margin: auto;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.grid-container {
    display: grid;
    grid-template-columns: repeat(var(--board-size, 9), 1fr);
    gap: 0.5rem;
    width: 100%;
    max-width: var(--board-max-width, 800px);
    aspect-ratio: 1 / 1;
    padding: 1rem;
}
.circle-button {
    position: relative;
    background-color: #0f172a; 
    width: 100%;
    padding-top: 100%;
    border-radius: 50%;
    border: 1px solid #334155; 
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.2);
}
.circle-button:not(.taken):hover {
    transform: scale(1.05);
    background-color: #1e293b;
    border-color: #475569;
}

.circle-button.taken {
    cursor: pointer;
    animation: captureEffect 0.5s ease-out;
}
.circle-button.taken:hover {
    transform: scale(1.05);
    filter: brightness(1.15);
}
@keyframes captureEffect {
    0% { transform: scale(0.8); opacity: 0.5; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.circle-button.taken .circle-number {
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5); 
}
.circle-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem; 
    font-weight: bold;
    color: #475569; 
    transition: color 0.3s ease;
}
.circle-button:not(.taken):hover .circle-number {
    color: #64748b;
}

.taken-yellow {
    background: radial-gradient(circle, var(--color-yellow-light) 0%, var(--color-yellow-dark) 100%);
    box-shadow: 0 0 12px var(--color-yellow-dark), 0 0 20px var(--color-yellow-dark), inset 0 2px 3px rgba(255,255,255,0.3);
    border: 1px solid var(--color-yellow-light);
}
.taken-red {
    background: radial-gradient(circle, var(--color-red-light) 0%, var(--color-red-dark) 100%);
    box-shadow: 0 0 12px var(--color-red-dark), 0 0 20px var(--color-red-dark), inset 0 2px 3px rgba(255,255,255,0.3);
    border: 1px solid var(--color-red-light);
}
.taken-blue {
    background: radial-gradient(circle, var(--color-blue-light) 0%, var(--color-blue-dark) 100%);
    box-shadow: 0 0 12px var(--color-blue-dark), 0 0 20px var(--color-blue-dark), inset 0 2px 3px rgba(255,255,255,0.3);
    border: 1px solid var(--color-blue-light);
}
.taken-green {
    background: radial-gradient(circle, var(--color-green-light) 0%, var(--color-green-dark) 100%);
    box-shadow: 0 0 12px var(--color-green-dark), 0 0 20px var(--color-green-dark), inset 0 2px 3px rgba(255,255,255,0.3);
    border: 1px solid var(--color-green-light);
}
.taken-purple {
    background: radial-gradient(circle, var(--color-purple-light) 0%, var(--color-purple-dark) 100%);
    box-shadow: 0 0 12px var(--color-purple-dark), 0 0 20px var(--color-purple-dark), inset 0 2px 3px rgba(255,255,255,0.3);
    border: 1px solid var(--color-purple-light);
}

/* Protected winning circles - golden border glow */
.circle-button.taken-yellow.protected {
    box-shadow: 0 0 12px var(--color-yellow-dark), 0 0 20px var(--color-yellow-dark), 0 0 8px #f97316, inset 0 2px 3px rgba(255,255,255,0.3);
    border: 2px solid #f97316;
}
.circle-button.taken-red.protected {
    box-shadow: 0 0 12px var(--color-red-dark), 0 0 20px var(--color-red-dark), 0 0 8px #fbbf24, inset 0 2px 3px rgba(255,255,255,0.3);
    border: 2px solid #fbbf24;
}
.circle-button.taken-blue.protected {
    box-shadow: 0 0 12px var(--color-blue-dark), 0 0 20px var(--color-blue-dark), 0 0 8px #fbbf24, inset 0 2px 3px rgba(255,255,255,0.3);
    border: 2px solid #fbbf24;
}
.circle-button.taken-green.protected {
    box-shadow: 0 0 12px var(--color-green-dark), 0 0 20px var(--color-green-dark), 0 0 8px #fbbf24, inset 0 2px 3px rgba(255,255,255,0.3);
    border: 2px solid #fbbf24;
}
.circle-button.taken-purple.protected {
    box-shadow: 0 0 12px var(--color-purple-dark), 0 0 20px var(--color-purple-dark), 0 0 8px #fbbf24, inset 0 2px 3px rgba(255,255,255,0.3);
    border: 2px solid #fbbf24;
}
@keyframes protectedPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); 
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal-content {
    background-color: #1e293b;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 90%;
    text-align: center;
    animation: slideIn 0.5s ease-out;
    position: relative;
    border: 1px solid #334155;
    max-height: 90vh;
    overflow-y: auto;
}
.question-modal .modal-content {
    max-width: 900px;
    padding: 3rem;
}
@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.answer-status-modal .modal-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}
.answer-status-modal .status-text {
    font-size: 3rem;
    font-weight: bold;
}
.answer-status-modal .status-icon {
    position: static;
    transform: none;
    font-size: 6rem;
    opacity: 1;
    animation: pulse-icon 1s ease-in-out infinite;
}
@keyframes pulse-icon {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* === Team Cards (score board replacement) === */
.team-cards-container {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 0.75rem;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: 1rem;
}

.team-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 2px solid rgba(255,255,255,0.08);
    background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.2) 100%);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    min-width: 120px;
    flex: 1;
    max-width: 200px;
    user-select: none;
}
.team-card:hover {
    transform: translateY(-3px);
    border-color: var(--team-color-light, #60a5fa);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* البطاقة النشطة (دور هذا الفريق) */
.team-card--active {
    border-color: var(--team-color-light, #60a5fa);
    background: linear-gradient(
        135deg,
        rgba(var(--team-color-light, 96, 165, 250), 0.12) 0%,
        rgba(0,0,0,0.25) 100%
    );
    box-shadow:
        0 0 0 1px var(--team-color-light, #60a5fa),
        0 0 16px var(--team-shadow, transparent),
        0 0 30px var(--team-shadow, transparent);
    animation: team-card-pulse 1.6s infinite ease-in-out;
}
@keyframes team-card-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px var(--team-color-light),
            0 0 12px var(--team-shadow),
            0 0 20px var(--team-shadow);
        transform: scale(1);
    }
    50% {
        box-shadow:
            0 0 0 2px var(--team-color-light),
            0 0 22px var(--team-shadow),
            0 0 40px var(--team-shadow);
        transform: scale(1.03);
    }
}

/* رأس البطاقة: الدائرة + الاسم + شارة الدور */
.team-card__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}
.team-card__dot {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: radial-gradient(circle, var(--team-color-light), var(--team-color-dark));
    flex-shrink: 0;
    box-shadow: 0 0 6px var(--team-shadow, transparent);
}
.team-card__name {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.team-card--active .team-card__name {
    color: var(--team-color-light);
}
.team-card__badge {
    font-size: 0.65rem;
    font-weight: 800;
    color: #0f172a;
    background: var(--team-color-light);
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    animation: badge-pop 0.3s ease;
}
@keyframes badge-pop {
    from { transform: scale(0.5); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* إحصاءات البطاقة */
.team-card__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: rgba(0,0,0,0.2);
    border-radius: 0.6rem;
    padding: 0.4rem 0.5rem;
}
.team-card__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    flex: 1;
}
.team-card__stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #f1f5f9;
    line-height: 1;
}
.team-card--active .team-card__stat-value {
    color: var(--team-color-light);
}
.team-card__stat-label {
    font-size: 0.65rem;
    color: #94a3b8;
    white-space: nowrap;
}
.team-card__divider {
    width: 1px;
    height: 2rem;
    background: rgba(255,255,255,0.1);
    flex-shrink: 0;
}

/* إخفاء game-info القديم لأنه صار مدمجاً في البطاقات */
#game-info {
    display: none;
}

#question-text {
    font-size: 2.25rem !important;
    margin-bottom: 2.5rem !important;
    font-family: 'HacenLiner', sans-serif;
}
.question-modal .answer-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2.5rem;
}
.question-modal .answer-button {
    background-color: #334155;
    color: #e2e8f0;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    font-weight: bold;
    font-size: 2rem;
    font-family: 'HacenLiner', sans-serif;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 1px solid #475569;
}
.question-modal .answer-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
    background-color: #475569; 
}
.text-gradient {
    background: linear-gradient(to right, #60a5fa, #a5b4fc); 
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.color-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; 
    margin-top: 0.5rem; 
}
.color-arrow {
    background-color: #334155;
    color: #e2e8f0;
    border: none;
    border-radius: 50%;
    width: 3rem; 
    height: 3rem; 
    font-size: 1.5rem; 
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.color-arrow:hover {
    background-color: #475569;
}
.color-display {
    width: 3rem; 
    height: 3rem; 
    border-radius: 50%;
    border: 4px solid #334155; 
    background-color: #1e293b; 
}

#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 200;
}
.toast {
    display: flex;
    align-items: center;
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem 1.25rem;
    border-radius: 9999px; 
    border: 1px solid #334155;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.21, 1.02, 0.73, 1); 
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast-icon {
    font-size: 1.25rem;
    margin-left: 0.75rem;
}
.toast-message {
    font-weight: bold;
}

.player-turn-pulse {
    animation: pulse-turn 1.5s infinite ease-in-out;
}
@keyframes pulse-turn {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 10px var(--shadow-color, transparent);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 20px var(--shadow-color, transparent), 0 0 30px var(--shadow-color, transparent);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 10px var(--shadow-color, transparent);
    }
}

.game-info-pulse {
    animation: pulse-info-text 1.5s infinite ease-in-out;
}
@keyframes pulse-info-text {
    0% { 
        transform: scale(1);
        text-shadow: 0 0 8px var(--shadow-color, transparent);
    }
    50% { 
        transform: scale(1.03);
        text-shadow: 0 0 16px var(--shadow-color, transparent), 0 0 24px var(--shadow-color, transparent);
    }
    100% { 
        transform: scale(1);
        text-shadow: 0 0 8px var(--shadow-color, transparent);
    }
}

/* (جديد: أزرار التحكم العلوية) */
.control-btn {
    background-color: #334155;
    color: #e2e8f0;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: 2px solid #475569;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}
.control-btn:hover {
    background-color: #475569;
    color: #fde047;
    transform: scale(1.1) rotate(10deg);
    border-color: #64748b;
}

/* أزرار التكبير/التصغير */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(51, 65, 85, 0.85);
    border: 2px solid #475569;
    border-radius: 9999px;
    padding: 0.2rem 0.4rem;
    backdrop-filter: blur(8px);
}
.zoom-btn {
    width: 2.4rem !important;
    height: 2.4rem !important;
    font-size: 1.3rem !important;
    font-weight: 900 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}
.zoom-btn:hover {
    transform: scale(1.15) !important;
    rotate: 0deg !important;
    color: #fde047 !important;
    background: rgba(255,255,255,0.08) !important;
    border-radius: 50%;
}
.zoom-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #cbd5e1;
    min-width: 2.5rem;
    text-align: center;
    letter-spacing: 0.02em;
    user-select: none;
}

/* إعداد نقطة التحويل للتكبير */
.game-container {
    transform-origin: top center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* (جديد: تنسيقات وضع المُقدم) */
body.host-mode {
    background: #0f172a;
    padding: 0.5rem;
}
body.host-mode .game-container {
    padding: 1rem;
    border-radius: 1rem;
    border: none;
    box-shadow: none;
}
body.host-mode h1.text-gradient {
    font-size: 2rem !important;
    margin-bottom: 1rem;
}
body.host-mode .team-cards-container {
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}
body.host-mode .team-card {
    padding: 0.4rem 0.6rem;
    min-width: 80px;
    border-radius: 0.6rem;
}
body.host-mode .team-card__name {
    font-size: 0.75rem;
}
body.host-mode .team-card__stat-value {
    font-size: 0.9rem;
}
body.host-mode .team-card__stat-label {
    font-size: 0.5rem;
}
body.host-mode #game-info {
    font-size: 1.5rem !important;
    margin-bottom: 1rem;
}
body.host-mode .grid-container {
    gap: 0.25rem;
    padding: 0;
    max-width: var(--board-max-width, 800px);
}
body.host-mode .circle-button {
    box-shadow: none;
}
body.host-mode .circle-number {
    font-size: 1.2rem;
}
body.host-mode .control-btn {
    display: none; /* إخفاء أزرار المساعدة والباركود في جوال المقدم */
}

/* زر الإجابة الصحيحة للمقدم */
.host-correct-answer {
    background-color: var(--color-green-dark) !important;
    border-color: var(--color-green-light) !important;
    color: white !important;
    box-shadow: 0 0 15px var(--color-green-dark) !important;
    position: relative;
}
.host-correct-answer::after {
    content: '✓ إجابة صحيحة';
    position: absolute;
    top: -10px;
    right: 10px;
    background: white;
    color: var(--color-green-dark);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}
.host-action-btns {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    width: 100%;
}
.host-action-btn {
    flex: 1;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 0.75rem;
    color: white;
    cursor: pointer;
    transition: transform 0.2s;
}
.host-action-btn:active {
    transform: scale(0.95);
}
.host-btn-yes { background-color: var(--color-green-dark); border: 2px solid var(--color-green-light); }
.host-btn-no { background-color: var(--color-red-dark); border: 2px solid var(--color-red-light); }

/* (تنسيق نافذة الشرح التي تم حذفها بالخطأ) */
.modal-body {
    max-height: 60vh;
    overflow-y: auto;
    text-align: right;
    padding: 0 1rem;
}
.modal-body h2 {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--color-blue-light);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    border-bottom: 2px solid #334155;
    padding-bottom: 0.5rem;
}
.modal-body p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}
.modal-body ul {
    list-style-type: disc;
    margin-right: 2rem;
    margin-bottom: 1rem;
}
.modal-body li {
    margin-bottom: 0.5rem;
}
.modal-body strong {
    color: #fde047;
    font-weight: bold;
}

/* --- Mobile Responsive Layout --- */
@media (max-width: 768px) {
    .game-container {
        padding: 1.5rem 1rem;
        border-radius: 1rem;
        gap: 1rem;
    }
    .grid-container {
        gap: 0.25rem;
        padding: 0.25rem;
    }
    .circle-number {
        font-size: 0.9rem;
    }
    .modal-content {
        padding: 1.5rem;
    }
    #timer-display {
        font-size: 3rem !important;
        margin-bottom: 1rem !important;
    }
    #question-text {
        font-size: 1.25rem !important;
        margin-bottom: 1.5rem !important;
    }
    .question-modal .answer-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-top: 1rem;
    }
    .question-modal .answer-button {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
    .team-cards-container {
        gap: 0.5rem;
    }
    .team-card {
        min-width: 100px;
        padding: 0.6rem 0.75rem;
    }
    .team-card__stat-value {
        font-size: 1.1rem;
    }
    .team-card__name {
        font-size: 0.85rem;
    }
    .help-btn {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.2rem;
        top: 0.5rem;
        right: 0.5rem;
    }
    body.host-mode {
        padding: 0;
    }
    body.host-mode .game-container {
        padding: 0.25rem;
    }
    body.host-mode .grid-container {
        max-width: 100%;
    }
}

@font-face { font-family: 'AAGalaxy'; src: url('../../fonts/AA-GALAXY.otf') format('opentype'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'HacenLiner'; src: url('../../fonts/Hacen-Liner-Print-out.ttf') format('truetype'); font-weight: normal; font-style: normal; font-display: swap; }
