:root {
    --theme-color: #003980;
    --theme-rgb: 0, 57, 128; 
    --theme-text-on-bg: #ffffff; /* المتغير الجديد للتحكم بلون النص على الأزرار */
    
    /* Light Mode Default */
    --main-bg: #f3f4f6; /* رمادي فاتح */
    --text-primary: #000000; 
    --text-secondary: #333333;
    --footer-text: #000000;
    
    /* Transparent Glass Style */
    --glass-bg: rgba(255, 255, 255, 0.2);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --input-bg: rgba(255, 255, 255, 0.5);
    --btn-hover: rgba(0, 0, 0, 0.05);
}

/* Dark Mode */
.dark {
    --main-bg: #000000; /* أسود تماماً */
    --text-primary: #ffffff;
    --text-secondary: #e2e8f0;
    --footer-text: #ffffff;
    
    --glass-bg: rgba(20, 20, 20, 0.6);
    --glass-border: rgba(255, 255, 255, 0.15);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --input-bg: rgba(255, 255, 255, 0.1);
    --btn-hover: rgba(255, 255, 255, 0.15);
}

html { font-size: 100%; transition: font-size 0.2s ease-out; height: 100%; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Tajawal', 'El Messiri', sans-serif;
    height: 100vh; height: 100dvh; overflow: hidden;
    background-color: var(--main-bg); 
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease; 
    user-select: none;
    display: flex; flex-direction: column;
    margin: 0; padding: 0;
}

/* Custom Utilities for Dynamic Text Colors */
.text-on-bg {
    color: var(--theme-text-on-bg) !important;
}
.bg-theme {
    background-color: var(--theme-color) !important;
}

#snow-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

#app-wrapper {
    flex: 1; display: flex; flex-direction: column;
    position: relative; z-index: 10; height: 100dvh; width: 100%; overflow: hidden;
}

/* Splash Screen */
#splash-screen {
    position: fixed; 
    top: 0; left: 0; 
    width: 100%; height: 100%; 
    background-color: var(--theme-color); 
    z-index: 99999; 
    display: none !important; 
    justify-content: center; 
    align-items: center; 
    flex-direction: column;
    transition: opacity 0.3s ease;
}

@media all and (display-mode: standalone) {
    #splash-screen { display: flex !important; }
}

.splash-title {
    font-family: 'Amiri', serif;
    font-size: 2.5rem;
    color: white;
    font-weight: bold;
    margin-bottom: 1rem;
}

.splash-dedication {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

/* --- Settings Styles --- */

/* الكارت */
.settings-card {
    background-color: transparent;
    border: 2px solid var(--theme-color);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: visible;
}

.dark .settings-card {
    background-color: transparent;
    border-color: var(--theme-color);
}

.card-header { margin-bottom: 15px; }
.card-title {
    color: var(--theme-color);
    font-weight: 800;
    font-size: 1.1rem;
    font-family: 'El Messiri', sans-serif;
}
.dark .card-title { color: var(--theme-color); }

/* الصفوف */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.dark .setting-row { border-bottom-color: rgba(255,255,255,0.1); }
.setting-row:last-child { border-bottom: none; margin-bottom: 0; }

.setting-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

/* أزرار التبديل (أفقية) */
.segment-control {
    display: flex;
    flex-direction: row; /* أفقي */
    gap: 5px;
    background: transparent;
    border: 1px solid var(--theme-color);
    border-radius: 10px;
    overflow: hidden;
    height: 36px;
    width: 100%;
    max-width: 200px; /* تحديد عرض للأزرار */
}

.segment-btn {
    flex: 1;
    padding: 0;
    font-size: 0.85rem;
    font-weight: bold;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    border: none;
    border-left: 1px solid var(--theme-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.dark .segment-btn { border-color: var(--theme-color); color: #ffffff; }
.segment-btn:last-child { border-left: none; }

.segment-btn.active {
    background-color: var(--theme-color);
    color: var(--theme-text-on-bg) !important;
}

/* تعديل الهجري */
.hijri-control {
    display: flex;
    align-items: center;
    gap: 8px;
}
.hijri-btn {
    width: 28px; height: 28px;
    background: transparent;
    border: 1px solid var(--theme-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}
.dark .hijri-btn { border-color: var(--theme-color); color: white; }

.hijri-val {
    font-weight: 800;
    width: 24px; text-align: center;
    color: var(--text-primary);
}

/* دوائر الألوان المحدثة لشكل المربع المتوهج */
.colors-grid {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.color-circle {
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.color-circle.selected {
    border-radius: 8px; /* شكل المربع */
    box-shadow: 0 0 12px var(--theme-color); /* توهج */
    transform: scale(1.15);
    border: 2px solid var(--text-primary);
}

/* أزرار التخصيص (Trigger for Slider) */
.trigger-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    border: 1px solid var(--theme-color);
    padding: 10px 15px;
    border-radius: 12px;
    color: var(--text-primary);
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
}
.dark .trigger-btn { border-color: var(--theme-color); }

.value-badge {
    background-color: var(--theme-color);
    color: var(--theme-text-on-bg);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

/* السلايدر المخفي */
.slider-container {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    padding: 0 5px;
}
.slider-container.show {
    max-height: 40px;
    opacity: 1;
    padding-top: 10px;
}

.thick-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #d1d5db;
    outline: none;
}
.thick-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--theme-color);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* الاهتزاز (4 أزرار) */
.segment-control.four-items {
    display: flex;
    gap: 5px;
    border: none;
    height: auto;
    width: 100%; max-width: 100%;
}
.segment-control.four-items .segment-btn {
    flex: 1;
    border-left: 1px solid var(--theme-color);
    border-radius: 8px;
    padding: 8px 0;
}

/* أزرار البيانات */
.data-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}
.action-btn {
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    text-align: center;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    color: var(--theme-text-on-bg);
    display: flex; align-items: center; justify-content: center;
}
.btn-blue { background: #3b82f6; }
.btn-grey { background: #6b7280; color: white; }

/* أزرار الدعم المحدثة لتكون شفافة ومحددة باللون */
.box-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-radius: 15px;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    background-color: transparent !important;
}
.box-btn:active { transform: scale(0.98); }

/* الأزرار السفلية */
.big-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.big-btn:active { transform: scale(0.98); }

.btn-dark-blue-solid {
    background-color: #003980;
    color: white;
}

.btn-glass-outline {
    background: transparent;
    border: 2px solid var(--theme-color);
    color: var(--theme-color);
    box-shadow: none;
}
.dark .btn-glass-outline {
    color: white;
    border-color: var(--theme-color);
}

/* تنسيق زر منصة X */
.btn-x-social {
    border-color: #000000 !important;
    color: #000000 !important;
}
.dark .btn-x-social {
    border-color: #ffffff !important;
    color: #ffffff !important;
}

/* باقي الستايلات القديمة (كما هي في ملفك الأصلي) */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
    border-radius: 1.25rem;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.btn-glass-custom {
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    font-weight: bold; 
    background: transparent;
    transition: all 0.2s ease;
}
.btn-glass-custom:active, .btn-glass-custom:hover {
    background-color: var(--btn-hover);
    transform: scale(0.98);
}

.bead-area {
    flex: 1 1 auto; 
    min-height: 60px;
    max-height: 35vh;
    width: 100%; position: relative;
    display: flex; justify-content: center; align-items: center;
    overflow: hidden; margin: 0; cursor: pointer;
    mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 15%, black 85%, transparent);
}
.bead-string { position: absolute; width: 4px; height: 100%; background: rgba(0,0,0,0.1); border-radius: 2px; z-index: 1; }
.dark .bead-string { background: rgba(255,255,255,0.15); }
.bead-track { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 2; top: -25px; pointer-events: none; }
.bead {
    width: 50px; height: 50px; border-radius: 50%; margin: 15px 0;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6), transparent), var(--theme-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); transition: all 0.2s ease; pointer-events: auto;
    border: 1px solid rgba(255,255,255,0.2);
}
.bead.active { transform: scale(1.15); filter: brightness(1.2); box-shadow: 0 0 25px var(--theme-color); }

.btn-primary {
    background: linear-gradient(135deg, var(--theme-color) 0%, rgba(var(--theme-rgb), 0.8) 100%);
    border: none; border-radius: 1rem; padding: 1rem;
    font-weight: 700; font-size: 1.2rem; box-shadow: 0 0.4rem 0 rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center; width: 100%;
    margin-bottom: 0;
    flex-shrink: 0;
}
.btn-primary:active { transform: translateY(0.25rem); box-shadow: 0 0.15rem 0 rgba(0,0,0,0.15); }

.counter-display {
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 800; color: var(--theme-color);
    font-family: 'Tajawal', sans-serif; text-shadow: 0 0.15rem 0.6rem rgba(var(--theme-rgb), 0.2);
    transition: filter 0.3s; line-height: 1;
    flex-shrink: 0;
    cursor: pointer;
}

.blur-sensitive { transition: filter 0.3s ease; }
body.is-blurred .blur-sensitive { filter: blur(12px); user-select: none; }

.zikr-box {
    background: transparent; backdrop-filter: blur(10px);
    border: 2px solid var(--theme-color); border-radius: 1.25rem; padding: 0.8rem;
    text-align: center; font-family: 'Amiri', serif; font-size: 1.2rem;
    font-weight: bold; color: var(--text-primary); min-height: 4rem;
    display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
    box-shadow: inset 0 0 1.25rem rgba(var(--theme-rgb), 0.05);
    flex-shrink: 0;
}

/* Modals Transition Fix */
.modal { 
    position: fixed; inset: 0; z-index: 50; 
    align-items: center; justify-content: center; 
    display: flex;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal.active { opacity: 1; visibility: visible; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); }
.modal-content {
    position: relative; background: var(--main-bg); color: var(--text-primary);
    border-radius: 1.5rem; padding: 1.5rem; width: 90%; max-width: 450px; max-height: 85vh;
    overflow-y: auto; box-shadow: 0 1.25rem 3rem rgba(0,0,0,0.5);
    transform: scale(0.95); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); border: 1px solid var(--glass-border);
}
.modal.active .modal-content { transform: scale(1); }

.xp-bar { width: 100%; height: 0.5rem; background: rgba(128,128,128,0.15); border-radius: 0.25rem; overflow: hidden; margin-top: 0.3rem; }
.dark .xp-bar { background: rgba(255,255,255,0.1); }
.xp-fill { height: 100%; background: var(--theme-color); width: 0%; transition: width 0.5s; }

.badge { padding: 0.6rem; border-radius: 1rem; background: transparent; text-align: center; opacity: 0.5; filter: grayscale(1); border: 1px solid var(--glass-border); transition: all 0.3s; }
.badge.unlocked { opacity: 1; filter: grayscale(0); border-color: var(--theme-color); background: rgba(var(--theme-rgb), 0.1); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: 0.6rem; }

.simple-tabs { display: flex; border-bottom: 1px solid rgba(128,128,128,0.2); }
.simple-tab-btn { flex: 1; padding: 1rem 0.5rem; text-align: center; border-bottom: 3px solid transparent; color: var(--text-secondary); background: none; border: none; cursor: pointer; font-weight: 600; transition: 0.2s; font-size: 0.9rem; }
.simple-tab-btn.active { color: var(--theme-color); border-bottom-color: var(--theme-color); }

.input-wrapper { display: flex; align-items: center; background: transparent; border-radius: 0.75rem; border: 2px solid var(--theme-color); padding: 0.3rem; }
.input-field { flex: 1; background: transparent; border: none; outline: none; font-size: 1.2rem; text-align: center; color: var(--text-primary); font-weight: bold; }
.input-field::placeholder { color: var(--text-secondary); opacity: 0.5; }

.share-btn {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px;
    border-radius: 12px; font-weight: bold; margin-bottom: 8px;
    background: transparent; border: 1px solid var(--glass-border);
    color: var(--text-primary); transition: 0.2s;
}
.share-btn:hover { background: var(--btn-hover); transform: translateX(-5px); }

/* iOS Guide Style */
#iosInstallGuide {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: rgba(20, 20, 20, 0.95); backdrop-filter: blur(10px);
    color: white; padding: 15px; z-index: 100;
    border-top: 2px solid var(--theme-color);
    text-align: center; animation: slideUp 0.5s ease;
}
@keyframes slideUp { from {transform: translateY(100%);} to {transform: translateY(0);} }

/* Responsive Improvements */
@media (min-width: 768px) {
    #app-wrapper {
        max-width: 800px;
        margin: 0 auto;
        border-left: 1px solid var(--glass-border);
        border-right: 1px solid var(--glass-border);
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
}

@media (max-height: 800px) {
    .glass-panel { padding: 0.5rem !important; }
    .p-4 { padding: 0.5rem !important; }
    .simple-tab-btn { padding: 0.5rem 0.25rem !important; }
    .text-xl { font-size: 1rem !important; }
    .counter-display { font-size: 3rem !important; }
    .bead-area { min-height: 80px !important; }
    .btn-primary { padding: 0.6rem !important; font-size: 1rem !important; }
    .w-10 { width: 2.2rem !important; height: 2.2rem !important; } 
    .zikr-box { min-height: 3rem !important; font-size: 1rem !important; padding: 0.5rem !important; }
    header { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
    #tab-home { gap: 0.25rem !important; }
}

body .text-gray-50, body .text-gray-100, body .text-gray-200, body .text-gray-300, body .text-gray-400, body .text-gray-500, body .text-gray-600, body .text-gray-700, body .text-gray-800, body .text-gray-900 { color: black !important; }
body.dark .text-gray-50, body.dark .text-gray-100, body.dark .text-gray-200, body.dark .text-gray-300, body.dark .text-gray-400, body.dark .text-gray-500, body.dark .text-gray-600, body.dark .text-gray-700, body.dark .text-gray-800, body.dark .text-gray-900 { color: white !important; }