:root {
    --primary: #1e293b;
    --primary-dark: #0f172a;
    --accent: #d4af37;
    --accent-light: #f3e5ab;
    --bg-body: #f8fafc;
    --surface: #ffffff;
    --text-main: #334155;
    --text-light: #64748b;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh;
    padding-top: 90px;
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Components */
/* Toast Container moved to bottom */

.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(20px);
    transition: 0.3s;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.toast.success {
    background: #d1fae5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--success);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.hidden {
    display: none !important;
}

#loader {
    position: fixed;
    inset: 0;
    background: var(--primary-dark);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;
}

/* Navbar Styles Updated */
.navbar {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 1200px;
    height: 70px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Unified Navigation Buttons (Profile & Menu) */
.nav-btn {
    width: 45px;
    height: 45px;
    background: var(--bg-body);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    cursor: pointer;
    border: 1px solid #e2e8f0;
}

.nav-btn:hover {
    background: var(--primary);
    color: var(--accent);
}

/* Brand/Logo */
.brand {
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    height: 45px;
    width: auto;
    object-fit: contain;
}

@media (max-width: 400px) {
    .brand-text {
        display: none;
    }
}

/* Hide text on small screens */

.notif-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* Dropdown General */
.dropdown {
    position: fixed;
    top: 95px;
    width: 280px;
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    transform: translateY(-10px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: 0.2s ease-out;
    z-index: 999;
    border: 1px solid #f1f5f9;
}

.dropdown.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Specific Dropdown Positions */
.user-dropdown {
    left: 5%;
}

.menu-dropdown {
    right: 5%;
}

@media (max-width: 768px) {
    .user-dropdown {
        left: 20px;
        width: 260px;
    }

    .menu-dropdown {
        right: 20px;
        width: 260px;
    }
}

.menu-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 25px 20px;
    border-radius: 1rem 1rem 0 0;
}

.menu-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f8fafc;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-main);
    transition: 0.2s;
    text-decoration: none;
}

.menu-item:hover {
    background: #f8fafc;
    color: var(--primary);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.card {
    background: var(--surface);
    border-radius: 1.5rem;
    padding: 30px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.challenge-hero {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #2c3e50 100%);
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transition: background 0.5s ease;
}

.challenge-label {
    display: inline-block;
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid rgba(212, 175, 55, 0.3);
    margin-bottom: 15px;
    position: relative;
    z-index: 2;
}

.challenge-content {
    position: relative;
    z-index: 2;
}

.winner-state .challenge-label {
    display: none;
}

.winner-state #displayQ {
    font-size: 1rem;
    opacity: 0.8;
    font-weight: 400;
    margin-bottom: 10px;
}

.winner-answer-box {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--accent);
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    margin: 15px 0;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--accent-light);
}

.admin-box {
    border: 2px dashed #cbd5e1;
    background: rgba(255, 255, 255, 0.6);
}

.tab-group {
    background: #e2e8f0;
    padding: 4px;
    border-radius: 30px;
    display: inline-flex;
}

.tab-btn {
    padding: 8px 20px;
    border-radius: 25px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-light);
    transition: 0.2s;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    border: 1px solid #f1f5f9;
    position: relative;
    z-index: 2;
}

.stat-detail-box {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    margin-top: 10px;
    font-size: 0.9rem
}

.stat-num {
    font-weight: bold;
    color: var(--primary);
}

input,
select,
textarea {
    width: 100%;
    padding: 16px;
    background: #f8fafc;
    border: 2px solid transparent;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 10px;
    transition: 0.3s;
}

input:focus,
select:focus,
textarea:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 41, 59, 0.1);
}

.input-error {
    border-color: var(--danger) !important;
    background: #fff1f2 !important;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

/* CSS Cleanup */

/* Button Boost */
.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer !important;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 100 !important;
    /* Force on top */
    pointer-events: auto !important;
    /* Force clickable */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-navy {
    background: var(--primary);
    color: white;
}

.btn-gold {
    background: linear-gradient(135deg, #d4af37, #bfa06a);
    color: white;
}

.btn-red {
    background: #fee2e2;
    color: var(--danger);
}

.btn-warning {
    background: #fffbeb;
    color: #b45309;
}

.answer-card {
    background: white;
    padding: 10px;
    border-radius: 16px;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    border: 1px solid #f1f5f9;
}

.user-avatar {
    width: 45px;
    height: 45px;
    flex-shrink: 0;
    background: #e2e8f0;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

.admin-controls {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #f1f5f9;
    align-items: center;
}

.id-badge {
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    border: 1px solid #bae6fd;
    margin-right: 8px;
    display: inline-block;
    font-weight: bold;
}

.ans-time {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    /* Default to checking through */
    transition: opacity 0.3s;
}

.overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.auth-card {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 40px 30px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* تنسيق زر العودة العائم */
.floating-back-btn {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 55px;
    height: 55px;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid #e2e8f0;
    border-radius: 590%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 998;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-back-btn:hover {
    background: var(--primary);
    color: var(--accent);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .floating-back-btn {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
        font-size: 1.3rem;
    }
}

@media (min-width: 768px) {
    .navbar {
        width: 85%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========================================= */
/* === Styles from HomeGAME.html (Accordion) === */
/* ========================================= */

.acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s;
    user-select: none;
}

.acc-header:hover {
    filter: brightness(0.95);
}

.acc-header .acc-arrow {
    transition: transform 0.3s;
    font-size: 1.2rem;
}

.acc-header.open .acc-arrow {
    transform: rotate(180deg);
}

.acc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.acc-body.open {
    max-height: 2000px;
}

.acc-body-inner {
    padding: 15px 5px 5px 5px;
}

/* ========================================= */
/* === Styles from SPACE_GAMES.HTML (Adapted for Light Theme) === */
/* ========================================= */

/* Base Body Override for SPACE_GAMES */
body.space-games {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Tajawal', sans-serif;
    padding-top: 90px;
    /* Match HomeGAME padding */
    min-height: 100vh;
}

/* Header for Space Games (Now consistent with HomeGAME) */
.space-header {
    text-align: center;
    padding: 2rem;
    background: transparent;
    border-bottom: none;
    margin-bottom: 20px;
}

.space-header h1 {
    margin: 0;
    font-size: 2.5rem;
    color: var(--primary);
    text-shadow: none;
}

.space-header p {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-top: 5px;
}

/* Hub Grid */
.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

/* Section Card (Adapted to look like .card) */
.section-card {
    background: var(--surface);
    border: 1px solid #f1f5f9;
    border-radius: 1.5rem;
    padding: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.section-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 15px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
    font-weight: 800;
}

/* Game List */
.game-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Button Overrides for Space Games */
.btn-main {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    filter: brightness(1.1);
}

.btn-back {
    background: white;
    color: var(--text-main);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

.btn-back:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-green {
    background-color: #22c55e !important;
    color: white !important;
}

.btn-green:hover {
    background-color: #16a34a !important;
}

.btn-red {
    background-color: #ef4444 !important;
    color: white !important;
}

.btn-red:hover {
    background-color: #dc2626 !important;
}

.btn-blue {
    background-color: #3b82f6 !important;
    color: white !important;
}

.btn-blue:hover {
    background-color: #2563eb !important;
}

/* Game Info Box (Replaces inline styles) */
.game-info-box {
    background: #f8fafc;
    padding: 25px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 1.3rem;
    line-height: 1.8;
    min-height: 80px;
    border: 1px solid #e2e8f0;
    color: var(--text-main);
}

.game-hint-box {
    display: none;
    background: #fef9c3;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    color: #854d0e;
    border: 1px solid #fde047;
    font-size: 0.95rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-light);
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}



.game-list li {
    background: #f8fafc;
    margin-bottom: 12px;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    color: var(--text-main);
}

.game-list li:hover {
    background: white;
    border-color: var(--accent);
    transform: translateX(-5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.game-screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.game-screen.active {
    display: block;
}

/* LawDle Game (Light Theme) */
.loldle-container {
    text-align: center;
    background: var(--surface);
    padding: 30px;
    border-radius: 1.5rem;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.search-box {
    margin: 30px auto;
    max-width: 600px;
    position: relative;
    display: flex;
    gap: 10px;
}

.search-box input {
    flex-grow: 1;
    padding: 15px 20px;
    font-size: 1.2rem;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.3s;
}

.search-box input:focus {
    border-color: var(--primary);
    background: white;
}

.search-box button {
    padding: 0 30px;
    border-radius: 12px;
}

.results-container {
    margin-top: 30px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.results-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 700px;
}

.results-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 10px;
    padding: 0 10px;
    font-weight: bold;
    color: var(--text-light);
}

.result-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 10px;
}

.result-box {
    background: white;
    padding: 15px 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    border: 2px solid #e2e8f0;
    font-weight: bold;
    font-size: 1.1rem;
    text-align: center;
    transition: all 0.5s ease;
    opacity: 0;
    transform: rotateX(-90deg);
    animation: flipIn 0.6s forwards;
    color: var(--text-main);
}

/* ... animations remain same ... */

.bg-green {
    background-color: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
}

.bg-yellow {
    background-color: #fef9c3 !important;
    color: #854d0e !important;
    border-color: #fde047 !important;
}

.bg-red {
    background-color: #fee2e2 !important;
    color: #991b1b !important;
    border-color: #fca5a5 !important;
}

.color-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    padding: 15px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

/* Leaderboard (Light Theme) */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
}

.leaderboard-table th {
    color: var(--primary);
    font-weight: 900;
}

.leaderboard-table tr:hover {
    background: #f8fafc;
}

/* Modal (Light Theme) */
.modal-content {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    border: none;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 400px;
    width: 90%;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-size: 1.1rem;
}

.loading-spinner::before {
    content: "⏳";
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .search-box {
        flex-direction: column;
    }

    .search-box button {
        padding: 15px;
    }

    .results-container {
        scrollbar-width: thin;
        scrollbar-color: var(--accent-blue) #0f172a;
    }
}

/* Modal Overlay (Hidden by default) */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: white;
    color: #1e293b;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 1px solid #e2e8f0;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-right: 5px solid #22c55e;
}

.toast.success i {
    color: #22c55e;
    font-size: 1.2rem;
}

.toast.error {
    border-right: 5px solid #ef4444;
}

.toast.error i {
    color: #ef4444;
    font-size: 1.2rem;
}

.toast.info {
    border-right: 5px solid #3b82f6;
}

.toast.info i {
    color: #3b82f6;
    font-size: 1.2rem;
}

/* Accordion Styles */
.acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.acc-header:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}

.acc-header.open .acc-arrow {
    transform: rotate(180deg);
}

.acc-arrow {
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.acc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.acc-body.open {
    max-height: 1000px;
    transition: max-height 0.5s ease-in;
}

.acc-body-inner {
    padding: 15px;
}