/* ==========================================================================
   مَعارِف | Ma3arf — DESIGN SYSTEM & TOKENS
   Modern Islamic Editorial Luxury — Calm, Refined, Educational, Accessible
   ========================================================================== */

:root {
    /* Fonts */
    --font-primary: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Tajawal', var(--font-primary);
    --font-quran: 'Amiri', 'Times New Roman', serif;

    /* Required Palette (Default Dark: Modern Islamic Editorial Luxury) */
    --bg-primary: #0B1512;
    --bg-secondary: #10211B;
    --bg-card: #172B23;
    --bg-card-hover: #1E372D;
    --bg-card-active: #244337;
    
    --color-primary: #2E8B68;
    --color-primary-rgb: 46, 139, 104;
    --color-primary-glow: rgba(46, 139, 104, 0.25);
    
    /* Refined Islamic Gold Palette (Editorial Luxury) */
    --gold-primary: #C6A15B;
    --gold-soft: #D8BD83;
    --gold-deep: #9C793B;
    --gold-tint: #E8D9B5;
    --gold-gradient: linear-gradient(135deg, #C6A15B 0%, #E8D9B5 50%, #9C793B 100%);
    --gold-glow: rgba(198, 161, 91, 0.28);
    --gold-border: rgba(198, 161, 91, 0.28);

    --color-secondary: var(--gold-primary);
    --color-secondary-rgb: 198, 161, 91;
    --color-secondary-glow: var(--gold-glow);
    
    --text-primary: #F4F1E8;
    --text-secondary: #B9C7BD;
    --text-muted: #7E9689;
    
    --border-color: #30463A;
    --border-light: rgba(198, 161, 91, 0.2);
    --border-focus: var(--gold-primary);

    /* Semantic Feedback Colors */
    --color-success: #2E8B68;
    --color-success-light: rgba(46, 139, 104, 0.25);
    --color-error: #E05D5D;
    --color-error-light: rgba(224, 93, 93, 0.22);
    --color-warning: #D7B56D;

    /* Shadows & Tactile Elevation */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.5);
    --glow-gold: 0 0 24px rgba(215, 181, 109, 0.35);
    --glow-emerald: 0 0 24px rgba(46, 139, 104, 0.3);

    /* Radii & Transitions */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides (Parchment & Emerald Luxury) */
html[data-theme="light"] {
    --bg-primary: #F8F6F0;
    --bg-secondary: #EFE9DE;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F6F2EB;
    --bg-card-active: #EFE8DC;
    
    --color-primary: #1C6B4F;
    --color-primary-rgb: 28, 107, 79;
    --color-primary-glow: rgba(28, 107, 79, 0.15);
    
    /* Refined Islamic Gold Palette (Light / Parchment) */
    --gold-primary: #B88E3E;
    --gold-soft: #CFA866;
    --gold-deep: #8C6826;
    --gold-tint: #F3EBD8;
    --gold-gradient: linear-gradient(135deg, #8C6826 0%, #B88E3E 50%, #CFA866 100%);
    --gold-glow: rgba(184, 142, 62, 0.2);
    --gold-border: rgba(184, 142, 62, 0.3);

    --color-secondary: var(--gold-primary);
    --color-secondary-rgb: 184, 142, 62;
    --color-secondary-glow: var(--gold-glow);
    
    --text-primary: #12221B;
    --text-secondary: #4A6357;
    --text-muted: #758D81;
    
    --border-color: #D6CCC0;
    --border-light: rgba(184, 142, 62, 0.2);
    --border-focus: var(--gold-primary);

    --color-success: #1C6B4F;
    --color-success-light: rgba(28, 107, 79, 0.15);
    --color-error: #C53B3B;
    --color-error-light: rgba(197, 59, 59, 0.15);
    --color-warning: #B88E3E;

    --shadow-sm: 0 2px 4px rgba(18, 34, 27, 0.05);
    --shadow-md: 0 6px 16px rgba(18, 34, 27, 0.08);
    --shadow-lg: 0 12px 30px rgba(18, 34, 27, 0.12);
    --glow-gold: 0 0 20px rgba(184, 142, 62, 0.2);
    --glow-emerald: 0 0 20px rgba(28, 107, 79, 0.15);
}

/* ==========================================================================
   GLOBAL RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    min-height: 100vh;
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    overflow-x: hidden;
    scroll-behavior: smooth;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

body {
    direction: rtl;
    text-align: right;
    padding-bottom: 72px; /* For mobile bottom nav */
}

@media (min-width: 769px) {
    body {
        padding-bottom: 0;
    }
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

button {
    font-family: var(--font-primary);
    border: none;
    outline: none;
    cursor: pointer;
    background: none;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 3px;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* ==========================================================================
   AUTHENTIC ISLAMIC GEOMETRIC BACKGROUND & AMBIENT GLOW
   8-Pointed Star (Khatim Sulayman / Rub el Hizb) Interlocking Tessellation
   ========================================================================== */
.islamic-pattern-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    opacity: 0.055;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23C6A15B' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='27' y='27' width='26' height='26'/%3E%3Crect x='27' y='27' width='26' height='26' transform='rotate(45 40 40)'/%3E%3Ccircle cx='40' cy='40' r='5' stroke-width='0.75'/%3E%3Crect x='-13' y='-13' width='26' height='26'/%3E%3Crect x='-13' y='-13' width='26' height='26' transform='rotate(45 0 0)'/%3E%3Crect x='67' y='-13' width='26' height='26'/%3E%3Crect x='67' y='-13' width='26' height='26' transform='rotate(45 80 0)'/%3E%3Crect x='67' y='67' width='26' height='26'/%3E%3Crect x='67' y='67' width='26' height='26' transform='rotate(45 80 80)'/%3E%3Crect x='-13' y='67' width='26' height='26'/%3E%3Crect x='-13' y='67' width='26' height='26' transform='rotate(45 0 80)'/%3E%3Cline x1='40' y1='14' x2='40' y2='0' stroke-width='1.1'/%3E%3Cline x1='40' y1='66' x2='40' y2='80' stroke-width='1.1'/%3E%3Cline x1='14' y1='40' x2='0' y2='40' stroke-width='1.1'/%3E%3Cline x1='66' y1='40' x2='80' y2='40' stroke-width='1.1'/%3E%3Cline x1='21.6' y1='21.6' x2='9.2' y2='9.2' stroke-width='0.9'/%3E%3Cline x1='58.4' y1='21.6' x2='70.8' y2='9.2' stroke-width='0.9'/%3E%3Cline x1='58.4' y1='58.4' x2='70.8' y2='70.8' stroke-width='0.9'/%3E%3Cline x1='21.6' y1='58.4' x2='9.2' y2='70.8' stroke-width='0.9'/%3E%3Cpolygon points='40,5 44,9 40,13 36,9' stroke-width='0.75'/%3E%3Cpolygon points='40,67 44,71 40,75 36,71' stroke-width='0.75'/%3E%3Cpolygon points='5,40 9,44 13,40 9,36' stroke-width='0.75'/%3E%3Cpolygon points='67,40 71,44 75,40 71,36' stroke-width='0.75'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 80px 80px;
    background-repeat: repeat;
}

html[data-theme="light"] .islamic-pattern-bg {
    opacity: 0.045;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23B88E3E' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='27' y='27' width='26' height='26'/%3E%3Crect x='27' y='27' width='26' height='26' transform='rotate(45 40 40)'/%3E%3Ccircle cx='40' cy='40' r='5' stroke-width='0.75'/%3E%3Crect x='-13' y='-13' width='26' height='26'/%3E%3Crect x='-13' y='-13' width='26' height='26' transform='rotate(45 0 0)'/%3E%3Crect x='67' y='-13' width='26' height='26'/%3E%3Crect x='67' y='-13' width='26' height='26' transform='rotate(45 80 0)'/%3E%3Crect x='67' y='67' width='26' height='26'/%3E%3Crect x='67' y='67' width='26' height='26' transform='rotate(45 80 80)'/%3E%3Crect x='-13' y='67' width='26' height='26'/%3E%3Crect x='-13' y='67' width='26' height='26' transform='rotate(45 0 80)'/%3E%3Cline x1='40' y1='14' x2='40' y2='0' stroke-width='1.1'/%3E%3Cline x1='40' y1='66' x2='40' y2='80' stroke-width='1.1'/%3E%3Cline x1='14' y1='40' x2='0' y2='40' stroke-width='1.1'/%3E%3Cline x1='66' y1='40' x2='80' y2='40' stroke-width='1.1'/%3E%3Cline x1='21.6' y1='21.6' x2='9.2' y2='9.2' stroke-width='0.9'/%3E%3Cline x1='58.4' y1='21.6' x2='70.8' y2='9.2' stroke-width='0.9'/%3E%3Cline x1='58.4' y1='58.4' x2='70.8' y2='70.8' stroke-width='0.9'/%3E%3Cline x1='21.6' y1='58.4' x2='9.2' y2='70.8' stroke-width='0.9'/%3E%3Cpolygon points='40,5 44,9 40,13 36,9' stroke-width='0.75'/%3E%3Cpolygon points='40,67 44,71 40,75 36,71' stroke-width='0.75'/%3E%3Cpolygon points='5,40 9,44 13,40 9,36' stroke-width='0.75'/%3E%3Cpolygon points='67,40 71,44 75,40 71,36' stroke-width='0.75'/%3E%3C/g%3E%3C/svg%3E");
}

.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}
.orb-1 {
    top: -100px;
    right: -100px;
    width: 450px;
    height: 450px;
    background: var(--color-primary-glow);
}
.orb-2 {
    bottom: -100px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: var(--color-secondary-glow);
}

.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Authentic Islamic Ornamental Accents */
.ornamental-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 24px auto;
    max-width: 480px;
    color: var(--gold-soft);
    font-size: 15px;
    opacity: 0.85;
    user-select: none;
}
.ornamental-divider::before,
.ornamental-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-border), transparent);
}
.ornamental-divider .divider-motif {
    letter-spacing: 6px;
    color: var(--gold-primary);
    filter: drop-shadow(0 0 6px var(--gold-glow));
}

.gold-accent-text {
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold-primary);
}

/* ==========================================================================
   HEADER SECTION
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background-color: rgba(11, 21, 18, 0.88);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

html[data-theme="light"] .app-header {
    background-color: rgba(248, 246, 240, 0.92);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.logo-icon {
    font-size: 26px;
    filter: drop-shadow(0 2px 10px var(--gold-glow));
}
.logo-text-group {
    display: flex;
    flex-direction: column;
}
.logo-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
    color: var(--gold-primary);
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
    line-height: 1.1;
}
.logo-subtext {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}

/* XP Level Badge in Header */
.xp-badge-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast);
}
.xp-badge-container:hover {
    border-color: var(--color-secondary);
}
.level-icon {
    font-size: 20px;
}
.xp-details {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}
.level-title-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.level-label {
    color: var(--text-secondary);
}
.level-value {
    color: var(--color-secondary);
    font-weight: 700;
}
.xp-progress-bar-wrapper {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 3px 0;
}
.xp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}
.xp-text-numbers {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    direction: ltr;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition-fast);
}
.header-action-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

.theme-toggle-btn {
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}
.theme-toggle-btn svg {
    color: var(--color-secondary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}
.theme-toggle-btn:hover svg {
    transform: rotate(15deg) scale(1.12);
}
html[data-theme="dark"] .theme-toggle-btn .moon-icon {
    display: inline-block;
}
html[data-theme="dark"] .theme-toggle-btn .sun-icon {
    display: none;
}
html[data-theme="light"] .theme-toggle-btn .moon-icon {
    display: none;
}
html[data-theme="light"] .theme-toggle-btn .sun-icon {
    display: inline-block;
}

/* ==========================================================================
   APP SCREENS & NAVIGATION
   ========================================================================== */
.app-main-content {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: calc(100vh - 80px);
}

.app-screen {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}
.app-screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================================================
   1. LANDING SCREEN
   ========================================================================== */
.hero-section {
    text-align: center;
    max-width: 860px;
    margin: 20px auto 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-geometric-badge {
    margin-bottom: 20px;
    display: inline-flex;
    padding: 12px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    box-shadow: var(--glow-gold);
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.25;
    margin-bottom: 14px;
}

.hero-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 640px;
    line-height: 1.8;
    margin-bottom: 28px;
}

/* Daily Knowledge Fact Preview Card (معلومة اليوم) */
.daily-fact-card-preview {
    width: 100%;
    max-width: 760px;
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 1px solid var(--border-color);
    border-right: 4px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 30px;
    text-align: right;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.daily-fact-card-preview:hover {
    transform: translateY(-2px);
    border-color: var(--color-secondary);
}
.daily-badge-tag {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(215, 181, 109, 0.15);
    color: var(--color-secondary);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}
.daily-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.daily-fact-txt {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-secondary);
    margin-bottom: 8px;
    line-height: 1.7;
}
.daily-exp-txt {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}
.daily-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.daily-source-txt {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* Quick Stats Row */
.quick-stats-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 32px;
    width: 100%;
}
.quick-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 160px;
    box-shadow: var(--shadow-sm);
}
.qs-num {
    font-size: 26px;
    font-weight: 800;
    color: var(--color-secondary);
    line-height: 1.1;
}
.qs-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons & CTAs */
.cta-actions {
    margin-bottom: 40px;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    transition: all var(--transition-fast);
    cursor: pointer;
}
.btn-primary {
    background: var(--color-primary);
    color: #FFFFFF;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
    background: #369c76;
    box-shadow: var(--glow-emerald);
    transform: translateY(-2px);
}
.btn-secondary {
    background: var(--color-secondary);
    color: #0B1512;
}
.btn-secondary:hover {
    background: #dfc27e;
    box-shadow: var(--glow-gold);
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
    background: var(--bg-card);
}
.btn-danger {
    background: var(--color-error);
    color: #FFFFFF;
}
.btn-danger:hover {
    background: #e87272;
}
.btn-lg {
    padding: 16px 36px;
    font-size: 17px;
    border-radius: var(--radius-lg);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}
.btn.disabled, .btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pulse-glow {
    animation: pulseGlow 2.5s infinite;
}
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 16px var(--color-primary-glow);
    }
    50% {
        box-shadow: 0 0 28px rgba(46, 139, 104, 0.4);
    }
}

/* Landing Quick Nav Cards Grid */
.landing-quick-nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    width: 100%;
}
.quick-nav-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    text-align: right;
    transition: all var(--transition-fast);
}
.quick-nav-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--color-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.nav-card-icon {
    font-size: 28px;
    flex-shrink: 0;
}
.nav-card-info h4 {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.nav-card-info p {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ==========================================================================
   2. SELECTION SCREEN (MODES, PRESETS, DIFFICULTY, CATEGORIES)
   ========================================================================== */
.selection-container {
    max-width: 960px;
    margin: 0 auto;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 20px;
    transition: all var(--transition-fast);
}
.back-btn:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

.section-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.section-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.subsection-title {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--color-secondary);
    margin-bottom: 12px;
}

/* Mode Selection (Challenge vs Learning) */
.mode-selection-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}
.mode-toggle-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.mode-toggle-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: right;
    transition: all var(--transition-fast);
}
.mode-toggle-btn:hover {
    border-color: var(--color-secondary);
    background: var(--bg-card-hover);
}
.mode-toggle-btn.active {
    border-color: var(--color-secondary);
    background: rgba(215, 181, 109, 0.08);
    box-shadow: var(--shadow-sm);
}
.mode-icon {
    font-size: 32px;
}
.mode-label {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
}
.mode-toggle-btn.active .mode-label {
    color: var(--color-secondary);
}
.mode-desc {
    display: block;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Question Count Selector */
.question-count-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}
.question-count-section {
    margin-bottom: 28px;
}
.count-options-wrapper {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-top: 10px;
}
@media (max-width: 820px) {
    .count-options-wrapper {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}
@media (max-width: 480px) {
    .count-options-wrapper {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}
.count-btn, .count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 14px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    text-align: center;
    outline: none;
    position: relative;
    min-height: 46px;
}
.count-btn:hover, .count-pill:hover {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--gold-glow);
}
.count-btn:active, .count-pill:active {
    transform: translateY(0);
}
.count-btn.active, .count-pill.active {
    background: var(--gold-gradient);
    color: #0B1512;
    border-color: var(--gold-primary);
    font-weight: 800;
    box-shadow: 0 4px 18px var(--gold-glow);
    transform: translateY(-2px);
}
html[data-theme="light"] .count-btn.active,
html[data-theme="light"] .count-pill.active {
    color: #12221B;
}

/* Tabs: Difficulty vs Categories */
.selection-tabs-header {
    margin-bottom: 16px;
}
.selection-tabs {
    display: flex;
    gap: 12px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
}
.tab-btn {
    padding: 10px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14.5px;
    font-weight: 700;
    transition: all var(--transition-fast);
}
.tab-btn:hover {
    color: var(--text-primary);
    border-color: var(--color-secondary);
}
.tab-btn.active {
    background: var(--color-secondary);
    color: #0B1512;
    border-color: var(--color-secondary);
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Difficulty Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}
.mode-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-secondary);
    box-shadow: var(--shadow-sm);
}
.mode-card.selected {
    border-color: var(--color-secondary);
    background: rgba(215, 181, 109, 0.08);
    box-shadow: var(--glow-gold);
}
.card-icon {
    font-size: 32px;
    margin-bottom: 10px;
}
.card-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.mode-card.selected .card-title {
    color: var(--color-secondary);
}
.card-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    flex-grow: 1;
}
.card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.card-action-btn {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.mode-card.selected .card-action-btn {
    background: var(--color-secondary);
    color: #0B1512;
    border-color: var(--color-secondary);
}

/* Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.category-card {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition-fast);
}
.category-card:hover {
    border-color: var(--gold-soft);
    transform: translateY(-2px);
}
.category-card.selected {
    border-color: var(--gold-primary);
    background: rgba(198, 161, 91, 0.12);
    box-shadow: 0 4px 16px var(--gold-glow);
}
.category-card-icon {
    font-size: 32px;
    margin-bottom: 6px;
}
.category-card-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.category-card.selected .category-card-title {
    color: var(--color-secondary);
}
.category-card-count {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* Setup Summary Bar */
.setup-summary-bar {
    position: sticky;
    bottom: 20px;
    background: var(--bg-card);
    border: 1.5px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}
.summary-info {
    display: flex;
    flex-direction: column;
}
.summary-label {
    font-size: 12px;
    color: var(--text-muted);
}
.summary-text {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-secondary);
}

/* ==========================================================================
   3. QUIZ SCREEN & ACTIVE QUESTION BOARD
   ========================================================================== */
.quiz-layout-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .quiz-layout-container {
        grid-template-columns: 1fr;
    }
}

/* Info Panel (Sidebar on desktop, Top on mobile) */
.quiz-info-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: var(--shadow-sm);
}

.quiz-progress-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.quiz-progress-text {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
}
.quiz-progress-text strong {
    color: var(--color-secondary);
    font-size: 16px;
}
.quiz-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.quiz-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.quiz-badge-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.info-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
}
.card-lbl {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}
.card-val {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}
.score-glow {
    color: var(--color-secondary);
}

/* Smart Timer Widget */
.smart-timer-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 8px auto;
}
.timer-progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.ring-bg {
    fill: none;
    stroke: var(--bg-primary);
    stroke-width: 8;
}
.ring-fill {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.9s linear, stroke var(--transition-fast);
}
.timer-warning .ring-fill {
    stroke: var(--color-error);
    animation: timerPulse 0.8s infinite alternate;
}
@keyframes timerPulse {
    from { stroke-width: 8; }
    to { stroke-width: 11; filter: drop-shadow(0 0 6px var(--color-error)); }
}

.timer-text-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.timer-digits {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}
.timer-warning .timer-digits {
    color: var(--color-error);
}
.timer-lbl {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Learning Mode Timer Replacement */
.learning-mode-active .timer-progress-ring {
    opacity: 0.3;
}
.learning-mode-active .timer-digits {
    font-size: 32px;
}

/* Question Board */
.question-board {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.q-difficulty-badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    background: rgba(46, 139, 104, 0.15);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.q-difficulty-badge.easy {
    background: rgba(46, 139, 104, 0.15);
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.q-difficulty-badge.medium {
    background: rgba(215, 181, 109, 0.15);
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}
.q-difficulty-badge.hard, .q-difficulty-badge.expert {
    background: rgba(224, 93, 93, 0.15);
    color: var(--color-error);
    border-color: var(--color-error);
}

.favorite-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}
.favorite-toggle-btn:hover {
    color: var(--color-error);
    border-color: var(--color-error);
}
.favorite-toggle-btn.active {
    background: rgba(224, 93, 93, 0.15);
    border-color: var(--color-error);
    color: var(--color-error);
}
.favorite-toggle-btn.active .heart-icon {
    fill: var(--color-error);
}

.question-body {
    margin-bottom: 24px;
}
.question-text {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Answer Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.option-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: right;
    transition: all var(--transition-fast);
    position: relative;
    user-select: none;
}
.option-card:hover:not(.disabled) {
    background: var(--bg-card-hover);
    border-color: var(--color-secondary);
    transform: translateX(-4px);
}
.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 800;
    color: var(--color-secondary);
    flex-shrink: 0;
}
.option-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex-grow: 1;
}

/* Correct & Incorrect States */
.option-card.correct {
    background: var(--color-success-light) !important;
    border-color: var(--color-success) !important;
}
.option-card.correct .option-letter {
    background: var(--color-success);
    color: #FFFFFF;
    border-color: var(--color-success);
}
.option-card.correct::after {
    content: "✓";
    font-size: 18px;
    font-weight: 900;
    color: var(--color-success);
    margin-right: auto;
}

.option-card.incorrect {
    background: var(--color-error-light) !important;
    border-color: var(--color-error) !important;
}
.option-card.incorrect .option-letter {
    background: var(--color-error);
    color: #FFFFFF;
    border-color: var(--color-error);
}
.option-card.incorrect::after {
    content: "✕";
    font-size: 18px;
    font-weight: 900;
    color: var(--color-error);
    margin-right: auto;
}

.option-card.disabled {
    cursor: default;
    pointer-events: none;
}

/* Educational Feedback Panel */
.feedback-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-right: 4px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}
.feedback-panel.correct-feedback {
    border-right-color: var(--color-success);
    background: rgba(46, 139, 104, 0.08);
}
.feedback-panel.incorrect-feedback {
    border-right-color: var(--color-error);
    background: rgba(224, 93, 93, 0.08);
}
.feedback-icon {
    font-size: 24px;
    flex-shrink: 0;
}
.feedback-title {
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 4px;
}
.correct-feedback .feedback-title {
    color: var(--color-success);
}
.incorrect-feedback .feedback-title {
    color: var(--color-error);
}
.feedback-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-line;
}

/* Quiz Footer */
.quiz-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}
.quiz-footer-secondary {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   4. RESULTS SCREEN
   ========================================================================== */
.results-container {
    max-width: 840px;
    margin: 0 auto;
    text-align: center;
}

.results-dashboard-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: center;
    background: var(--bg-card);
    border: 1.5px solid var(--gold-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin: 28px 0;
    box-shadow: var(--shadow-md), 0 0 20px rgba(198, 161, 91, 0.08);
}

@media (max-width: 768px) {
    .results-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.score-radial-widget {
    display: flex;
    justify-content: center;
}
.radial-container {
    position: relative;
    width: 160px;
    height: 160px;
}
.radial-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.r-bg {
    fill: none;
    stroke: var(--bg-primary);
    stroke-width: 12;
}
.r-fill {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.radial-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.radial-percent {
    display: block;
    font-size: 34px;
    font-weight: 800;
    color: var(--gold-primary);
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}
.radial-score-txt {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.results-breakdown-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: right;
}
.details-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.detail-label {
    color: var(--text-secondary);
}
.detail-value {
    font-weight: 700;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    margin-bottom: 28px;
}

/* Newly Unlocked Badges Panel */
.new-badges-unlock-panel {
    background: rgba(215, 181, 109, 0.1);
    border: 1.5px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 28px;
    box-shadow: var(--glow-gold);
}
.panel-subtitle {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-secondary);
    margin-bottom: 14px;
}
.unlocked-badges-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

/* Detailed Answers Review Accordion */
.review-accordion-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 30px;
    text-align: right;
}
.accordion-header {
    width: 100%;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}
.accordion-header:hover {
    background: var(--bg-card-hover);
}
.accordion-arrow {
    transition: transform var(--transition-fast);
}
.accordion-header.active .accordion-arrow {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--bg-primary);
}

.review-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 18px;
}
.review-q-text {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.review-q-cat {
    color: var(--color-secondary);
    font-size: 12px;
}
.review-answers-compare {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}
.ans-comp-row {
    display: flex;
    gap: 8px;
}
.ans-comp-lbl {
    color: var(--text-muted);
    min-width: 110px;
}
.ans-comp-val {
    color: var(--text-primary);
}

/* ==========================================================================
   5. FAVORITES, WRONG REVIEW & SEARCH SCREENS
   ========================================================================== */
.screen-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.empty-state-card {
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    margin: 40px 0;
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.empty-state-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
}
.empty-state-card p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 480px;
    margin: 0 auto;
}

.favorites-list-grid, .wrong-answers-list-grid, .search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.favorite-item-card, .wrong-item-card, .search-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}
.favorite-item-card:hover, .wrong-item-card:hover, .search-result-card:hover {
    border-color: var(--color-secondary);
    transform: translateY(-2px);
}
.fav-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}
.fav-card-cat {
    color: var(--color-secondary);
    font-weight: 700;
}
.fav-card-diff {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    background: var(--bg-primary);
}
.fav-card-question {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.5;
}
.fav-card-answer {
    font-size: 13px;
    font-weight: 600;
}
.fav-card-explanation {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.fav-card-source {
    font-size: 11.5px;
    color: var(--color-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}
.remove-fav-btn {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.remove-fav-btn:hover {
    color: var(--color-error);
}
.mark-understood-btn {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-glow);
    color: var(--color-primary);
    font-size: 11.5px;
    font-weight: 700;
    border: 1px solid var(--color-primary);
    cursor: pointer;
}
.mark-understood-btn:hover {
    background: var(--color-primary);
    color: #FFFFFF;
}

/* Search Controls Card */
.search-controls-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.search-input-wrapper {
    position: relative;
    width: 100%;
}
.search-text-input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 15px;
    transition: border-color var(--transition-fast);
}
.search-text-input:focus {
    border-color: var(--color-secondary);
    outline: none;
}
.search-icon-inside {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.search-filter-select {
    padding: 8px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 13px;
    cursor: pointer;
}
.search-count-badge {
    font-size: 13px;
    color: var(--text-muted);
}
.search-fav-btn {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}
.search-fav-btn.active {
    color: var(--color-secondary);
}

/* ==========================================================================
   6. DAILY CHALLENGE & DAILY KNOWLEDGE SCREEN
   ========================================================================== */
.daily-screen-date-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    color: var(--color-secondary);
    margin-bottom: 12px;
}

.daily-challenge-master-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 1.5px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
    box-shadow: var(--glow-gold);
}
@media (max-width: 768px) {
    .daily-challenge-master-card {
        flex-direction: column;
        text-align: center;
    }
}
.dc-icon {
    font-size: 48px;
}
.dc-content {
    flex-grow: 1;
}
.dc-content h3 {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.dc-content p {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
}
.status-badge.ready {
    background: rgba(46, 139, 104, 0.2);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.status-badge.completed {
    background: rgba(215, 181, 109, 0.2);
    color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
}

.daily-knowledge-full-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   7. MODALS (STATS, RESET CONFIRMATION)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalPop 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: var(--color-secondary);
}
.close-modal-btn {
    font-size: 26px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.close-modal-btn:hover {
    color: var(--text-primary);
}

.modal-body-scroll {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.stat-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}
.stat-box-val {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}
.stat-box-lbl {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.modal-sub-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.badge-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.badge-item.unlocked {
    border-color: var(--color-secondary);
    box-shadow: var(--shadow-sm);
}
.badge-item.locked {
    opacity: 0.5;
    filter: grayscale(80%);
}
.badge-medal-icon {
    font-size: 32px;
    margin-bottom: 6px;
}
.badge-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.badge-desc-tip {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}
.badge-status-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-secondary);
}

.reset-data-container {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    text-align: center;
}

/* Reset Confirmation Modal */
.reset-modal-card {
    max-width: 460px;
    text-align: center;
    padding: 28px;
}
.reset-warning-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.reset-modal-card h3 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 10px;
}
.reset-modal-card p {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}
.reset-warning-text {
    color: var(--color-error) !important;
    font-weight: 700;
}
.reset-modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

/* ==========================================================================
   8. TOAST NOTIFICATIONS & CONFETTI
   ========================================================================== */
.achievement-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    background: var(--bg-card);
    border: 2px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--glow-gold);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
}
.achievement-toast.show {
    transform: translateY(0);
    opacity: 1;
}
.achievement-toast.hidden {
    display: none;
}
.toast-icon {
    font-size: 36px;
}
.toast-content {
    display: flex;
    flex-direction: column;
}
.toast-alert-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-secondary);
}
.toast-badge-name {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}
.toast-badge-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 250;
    overflow: hidden;
}

/* ==========================================================================
   9. MOBILE BOTTOM NAVIGATION BAR
   ========================================================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 64px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    flex-grow: 1;
    height: 100%;
    transition: color var(--transition-fast);
}
.nav-item svg {
    color: currentColor;
}
.nav-item:hover, .nav-item.active {
    color: var(--color-secondary);
}

/* ==========================================================================
   9.1. FOOTER SECTION — SADAQAH JARIYAH & CREDITS
   ========================================================================== */
.app-footer {
    position: relative;
    z-index: 10;
    width: 100%;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    border-top: 1px solid var(--border-color);
    padding: 48px 20px 96px; /* Extra padding for mobile bottom nav */
    margin-top: 40px;
}

@media (min-width: 769px) {
    .app-footer {
        padding: 48px 20px 40px;
    }
}

.footer-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.footer-ornament {
    display: flex;
    justify-content: center;
    line-height: 1;
}

/* Sadaqah Jariyah Card */
.sadaqah-card {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-right: 4px solid var(--color-secondary);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.sadaqah-card:hover {
    border-color: var(--color-secondary);
    transform: translateY(-2px);
}
.sadaqah-icon {
    font-size: 38px;
    flex-shrink: 0;
    line-height: 1;
}
.sadaqah-text-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sadaqah-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    color: var(--color-secondary);
    line-height: 1.3;
}
.sadaqah-desc {
    font-size: 14.5px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Share Callout Box */
.share-invitation-box {
    width: 100%;
    background: rgba(46, 139, 104, 0.08);
    border: 1.5px solid rgba(46, 139, 104, 0.3);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.hadith-quote {
    display: inline-block;
    font-family: var(--font-quran);
    font-size: 22px;
    font-weight: 700;
    color: var(--color-secondary);
    background: rgba(215, 181, 109, 0.12);
    border: 1px solid rgba(215, 181, 109, 0.25);
    padding: 8px 24px;
    border-radius: var(--radius-full);
    margin-bottom: 16px;
    line-height: 1.6;
}
.hadith-ref {
    display: block;
    font-family: var(--font-primary);
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}
.share-appeal-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.85;
    max-width: 720px;
    margin: 0 auto 22px;
    font-weight: 500;
}
.share-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}
.btn-share {
    box-shadow: var(--glow-gold);
}
.btn-copy {
    background: var(--bg-card);
}
.btn-copy:hover {
    border-color: var(--color-secondary);
    color: var(--color-secondary);
}

/* Bottom Credits */
.footer-bottom-credits {
    width: 100%;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.credits-developer {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.dev-name {
    color: var(--color-secondary);
    font-size: 16px;
    font-weight: 800;
}
.rights-tag {
    font-size: 12.5px;
    color: var(--text-muted);
}
.credits-platform {
    font-size: 12px;
    color: var(--text-muted);
}

/* ==========================================================================
   10. UTILITIES, HELPERS & ACCESSIBILITY
   ========================================================================== */
.text-gold { color: var(--color-secondary) !important; }
.text-green { color: var(--color-success) !important; }
.text-red { color: var(--color-error) !important; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ==========================================================================
   PHOSPHOR DUOTONE & AUTHENTIC ISLAMIC ICON SYSTEM
   ========================================================================== */
.ph-duotone {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    fill: currentColor;
    flex-shrink: 0;
    line-height: 1;
    transition: color var(--transition-fast), transform var(--transition-fast);
}
.ph-duotone path[opacity="0.2"],
.ph-duotone .ph-secondary {
    opacity: 0.22;
    fill: currentColor;
}
.ph-duotone path:not([opacity="0.2"]):not(.ph-secondary),
.ph-duotone .ph-primary {
    opacity: 1;
    fill: currentColor;
}

/* Sizing scale */
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 28px; height: 28px; }
.icon-2xl { width: 32px; height: 32px; }
.icon-hero { width: 44px; height: 44px; }

/* Colors */
.icon-gold { color: var(--color-secondary) !important; }
.icon-gold path[opacity="0.2"] { opacity: 0.32; }
.icon-green { color: var(--color-success) !important; }
.icon-red { color: var(--color-error) !important; }
.icon-primary { color: var(--color-primary) !important; }
.icon-muted { color: var(--text-muted) !important; }
.icon-silver { color: #d1d5db !important; }
.icon-bronze { color: #d97706 !important; }

/* Category Cards Icon Wrapper */
.cat-icon svg {
    width: 32px;
    height: 32px;
    color: var(--color-secondary);
    transition: transform var(--transition-fast);
}
.category-card:hover .cat-icon svg {
    transform: scale(1.1);
}

.badge-card .badge-icon svg,
.badge-item .badge-medal-icon svg {
    width: 36px;
    height: 36px;
    color: var(--color-secondary);
    display: inline-block;
}

.level-icon svg {
    display: inline-block;
    vertical-align: middle;
}

/* ==========================================================================
   11. ADVANCED FEATURES: SOUND, CHALLENGE, REVIEW, LEADERBOARD & FEEDBACK
   ========================================================================== */
.modal-card.modal-card-lg {
    max-width: 680px;
    width: 95%;
}

.btn-emoji {
    font-size: 16px;
    margin-left: 4px;
}

.sound-toggle-btn {
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast);
}
.sound-toggle-btn:hover {
    transform: scale(1.08);
}
.sound-toggle-btn.muted {
    opacity: 0.65;
    filter: grayscale(1);
}

.feedback-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.feedback-action-btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
}

/* Leaderboard Screen */
.leaderboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.active-profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.profile-info-mini {
    display: flex;
    align-items: center;
    gap: 8px;
}
.profile-badge-icon {
    font-size: 26px;
}
.profile-sub-lbl {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}
.profile-name-txt {
    font-size: 14.5px;
    color: var(--color-secondary);
    font-weight: 700;
}

.leaderboard-podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 14px;
    align-items: flex-end;
    margin: 24px 0;
}
.podium-slot {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px 12px;
    text-align: center;
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform var(--transition-base);
}
.podium-slot:hover {
    transform: translateY(-4px);
}
.podium-slot.rank-1 {
    border-color: var(--gold-primary);
    background: linear-gradient(180deg, rgba(198, 161, 91, 0.2), var(--bg-card));
    min-height: 200px;
    order: 2;
    box-shadow: 0 10px 25px var(--gold-glow);
}
.podium-slot.rank-2 {
    border-color: #A0B2C6;
    background: linear-gradient(180deg, rgba(160, 178, 198, 0.12), var(--bg-card));
    min-height: 175px;
    order: 1;
}
.podium-slot.rank-3 {
    border-color: #CD7F32;
    background: linear-gradient(180deg, rgba(205, 127, 50, 0.12), var(--bg-card));
    min-height: 155px;
    order: 3;
}
.podium-crown {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 4px;
}
.podium-rank-badge {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    margin-bottom: 8px;
}
.rank-1 .podium-rank-badge {
    background: var(--color-secondary);
    color: var(--bg-primary);
}
.rank-2 .podium-rank-badge {
    background: #A0B2C6;
    color: var(--bg-primary);
}
.rank-3 .podium-rank-badge {
    background: #CD7F32;
    color: #FFF;
}
.podium-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.podium-score {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-secondary);
    margin-bottom: 2px;
}
.podium-xp {
    font-size: 12px;
    color: var(--text-muted);
}
.podium-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.leaderboard-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 16px;
}
.leaderboard-table-header {
    display: grid;
    grid-template-columns: 70px 1.5fr 1fr 1fr 1.5fr 1fr;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    font-weight: 700;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    text-align: center;
}
.leaderboard-row {
    display: grid;
    grid-template-columns: 70px 1.5fr 1fr 1fr 1.5fr 1fr;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
    text-align: center;
    font-size: 13.5px;
    transition: background 0.15s ease;
}
.leaderboard-row:hover {
    background: rgba(215, 181, 109, 0.05);
}
.leaderboard-row.current-user-row {
    background: rgba(215, 181, 109, 0.08);
    font-weight: 700;
}
.leaderboard-local-note {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(46, 139, 104, 0.1);
    border: 1px solid rgba(46, 139, 104, 0.25);
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.6;
}

/* Share Modal */
.share-canvas-container {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    background: rgba(0, 0, 0, 0.35);
    padding: 14px;
    border-radius: var(--radius-md);
}
.share-card-canvas-preview {
    max-width: 320px;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 2px solid var(--color-secondary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.share-textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 10px;
    font-family: var(--font-primary);
    font-size: 13px;
    resize: none;
    direction: rtl;
    line-height: 1.5;
}
.share-modal-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

/* Quiz Review Modal */
.review-status-summary-bar {
    display: flex;
    justify-content: space-around;
    background: var(--bg-surface);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-bottom: 16px;
}
.rev-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.quiz-review-items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 380px;
    overflow-y: auto;
    padding-left: 4px;
}
.quiz-review-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    gap: 12px;
    transition: border-color 0.15s ease;
}
.quiz-review-item.answered {
    border-right: 4px solid var(--color-success);
}
.quiz-review-item.unanswered {
    border-right: 4px solid var(--color-secondary);
}
.review-item-q {
    flex: 1;
    text-align: right;
}
.review-item-q-num {
    font-weight: 800;
    color: var(--color-secondary);
    margin-left: 6px;
}
.review-item-q-title {
    font-size: 13.5px;
    color: var(--text-primary);
}
.review-status-pill {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    white-space: nowrap;
}
.review-status-pill.answered {
    background: rgba(46, 139, 104, 0.15);
    color: var(--color-success);
}
.review-status-pill.unanswered {
    background: rgba(215, 181, 109, 0.15);
    color: var(--color-secondary);
}
.review-modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* Feedback & Suggestions Modal */
.feedback-tabs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}
.feedback-tab-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.feedback-tab-btn.active {
    background: var(--color-secondary);
    color: var(--bg-primary);
    border-color: var(--color-secondary);
}
.suggest-options-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.suggest-opt-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.opt-indicator {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: var(--color-secondary);
}
.feedback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.btn-whatsapp-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #25D366 !important;
    color: #ffffff !important;
    border: 1px solid #1eb855 !important;
    font-weight: 700;
    transition: all var(--transition-fast);
}
.btn-whatsapp-action svg {
    flex-shrink: 0;
}
.btn-whatsapp-action:hover {
    background: #20ba5a !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
    color: #ffffff !important;
}

/* Direct WhatsApp Contact Box inside Modal */
.developer-wa-contact-box {
    margin-top: 22px;
    padding: 14px 18px;
    background: rgba(37, 211, 102, 0.08);
    border: 1px solid rgba(37, 211, 102, 0.28);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.wa-contact-icon {
    font-size: 24px;
    line-height: 1;
}
.wa-contact-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 190px;
}
.wa-contact-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
}
.wa-contact-sub {
    font-size: 11.5px;
    color: var(--text-secondary);
}
.wa-contact-link-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25D366;
    color: #ffffff !important;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
    white-space: nowrap;
}
.wa-contact-link-pill:hover {
    background: #20ba5a;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.42);
}

/* Footer WhatsApp Badge */
.footer-wa-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(37, 211, 102, 0.12);
    color: #25D366 !important;
    border: 1px solid rgba(37, 211, 102, 0.35);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.footer-wa-badge:hover {
    background: #25D366;
    color: #ffffff !important;
    border-color: #25D366;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 211, 102, 0.35);
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 13.5px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(215, 181, 109, 0.2);
}
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Source Details Modal */
.source-verification-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(46, 139, 104, 0.15);
    border: 1px solid var(--color-success);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    color: var(--color-success);
    font-weight: 700;
    font-size: 13.5px;
    margin-bottom: 16px;
}
.source-card-main {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: right;
}
.source-lbl {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}
.source-q-preview h4 {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
}
.source-meta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.meta-pill {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}
.source-reference-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-gold);
    padding: 12px 16px;
    border-radius: var(--radius-md);
}
.ref-quote {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-secondary);
    font-family: var(--font-heading);
}
.source-explanation-box {
    background: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    line-height: 1.7;
    font-size: 13.5px;
}
.source-modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

/* Profiles Modal */
.profiles-list-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}
.profile-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}
.profile-item-row.active {
    border-color: var(--color-secondary);
    background: rgba(215, 181, 109, 0.08);
}
.create-profile-box {
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}
.input-with-btn {
    display: flex;
    gap: 8px;
}

/* Challenge Welcome Modal */
.challenge-hero-icon {
    font-size: 48px;
    margin-bottom: 8px;
}
.challenge-lead-text {
    font-size: 18px;
    margin-bottom: 6px;
}
.challenge-sub-text {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.challenge-specs-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    text-align: right;
}
.spec-row {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
}
.challenge-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Universal Touch & Ergonomic Optimizations (Flutter & Mobile-First) */
button, 
.btn, 
.option-card, 
.count-btn, 
.tab-btn, 
.category-card, 
.mode-card, 
.nav-item, 
.quick-nav-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* In-Quiz Full-Focus Mode (Hides Bottom Nav, Maximizes Real Estate) */
body.in-quiz-session {
    padding-bottom: 0 !important;
}
body.in-quiz-session .bottom-nav {
    display: none !important;
}
body.in-quiz-session .app-main-content {
    padding: 8px 10px 20px !important;
    min-height: calc(100vh - 60px);
}

/* ==========================================================================
   MOBILE & TOUCH APP EXPERIENCE OVERHAUL (FLUTTER / GOOGLE PLAY READY)
   ========================================================================== */
@media (max-width: 768px) {
    /* Safe Area Inset Support */
    body {
        padding-bottom: max(68px, env(safe-area-inset-bottom, 68px));
    }

    /* 1. App Header on Mobile */
    .app-header {
        padding: 0;
    }
    .header-container {
        padding: 8px 12px;
        gap: 8px;
    }
    .logo-icon svg {
        width: 22px;
        height: 22px;
    }
    .logo-arabic {
        font-size: 19px;
    }
    .logo-subtext {
        display: none;
    }
    .xp-badge-container {
        padding: 4px 8px;
        gap: 6px;
    }
    .level-icon {
        font-size: 16px;
    }
    .xp-details {
        min-width: 75px;
    }
    .level-title-container {
        font-size: 11px;
    }
    .level-label {
        display: none;
    }
    .xp-progress-bar-wrapper {
        height: 4px;
        margin: 2px 0;
    }
    .xp-text-numbers {
        font-size: 9px;
    }
    .header-left {
        gap: 6px;
    }
    .header-action-btn {
        padding: 6px 8px;
        min-width: 36px;
        height: 36px;
        justify-content: center;
    }
    /* Hide text labels on mobile header to avoid overflow */
    #open-stats-btn span:not(.btn-icon),
    #open-feedback-header-btn span:not(.btn-emoji) {
        display: none;
    }

    /* 2. Main Content Wrapper */
    .app-main-content {
        padding: 12px 12px 76px;
    }

    /* 3. Quiz Screen — Compact HUD & Ergonomic Thumb Layout */
    .quiz-layout-container {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* Compact Top Info HUD (Takes only ~58px instead of 420px!) */
    .quiz-info-panel {
        padding: 8px 12px;
        border-radius: var(--radius-md);
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas: 
            "meta timer"
            "prog prog";
        gap: 6px 12px;
        align-items: center;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow-sm);
    }

    .quiz-badge-info {
        grid-area: meta;
        display: flex;
        gap: 6px;
        align-items: center;
        flex-wrap: wrap;
    }
    .info-card {
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        background: var(--bg-primary);
        border: 1px solid var(--border-subtle);
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .card-lbl {
        display: none;
    }
    .card-val {
        font-size: 12px;
        font-weight: 700;
        margin-top: 0;
        line-height: 1.2;
    }

    .smart-timer-container {
        grid-area: timer;
        width: 44px;
        height: 44px;
        margin: 0;
        flex-shrink: 0;
    }
    .smart-timer-container .ring-bg,
    .smart-timer-container .ring-fill {
        stroke-width: 10;
    }
    .smart-timer-container .timer-digits {
        font-size: 16px;
        font-weight: 800;
    }
    .smart-timer-container .timer-lbl {
        display: none;
    }

    .quiz-progress-section {
        grid-area: prog;
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
        margin-top: 2px;
    }
    .quiz-progress-text {
        font-size: 11.5px;
        display: flex;
        justify-content: space-between;
        color: var(--text-muted);
    }
    .quiz-progress-text strong {
        font-size: 13px;
    }
    .quiz-progress-bar {
        height: 5px;
    }

    /* Question Board on Mobile */
    .question-board {
        padding: 14px 14px 12px;
        border-radius: var(--radius-md);
    }
    .question-header {
        margin-bottom: 8px;
    }
    .q-difficulty-badge {
        padding: 3px 8px;
        font-size: 11px;
    }
    .favorite-toggle-btn {
        padding: 3px 8px;
        font-size: 11px;
    }
    .question-body {
        margin-bottom: 12px;
    }
    .question-text {
        font-size: 17px;
        line-height: 1.48;
        font-weight: 700;
    }

    /* Options Grid */
    .options-grid {
        gap: 8px;
        margin-bottom: 14px;
    }
    .option-card {
        padding: 10px 12px;
        min-height: 48px;
        border-radius: var(--radius-md);
        gap: 10px;
    }
    .option-letter {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    .option-text {
        font-size: 14.5px;
        font-weight: 600;
        line-height: 1.35;
    }

    /* Educational Feedback */
    .feedback-panel {
        padding: 10px 12px;
        gap: 8px;
        margin-bottom: 12px;
    }
    .feedback-icon {
        font-size: 20px;
    }
    .feedback-title {
        font-size: 13.5px;
    }
    .feedback-desc {
        font-size: 12px;
        line-height: 1.55;
    }
    .feedback-actions-row {
        gap: 6px;
        margin-top: 8px;
    }
    .feedback-action-btn {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Quiz Footer Actions — Thumb-Zone Optimized */
    .quiz-footer {
        display: flex;
        flex-direction: column-reverse;
        gap: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }
    .quiz-footer #next-question-btn {
        width: 100%;
        height: 48px;
        font-size: 16px;
        font-weight: 800;
        justify-content: center;
        border-radius: var(--radius-md);
        box-shadow: 0 4px 14px var(--gold-glow);
    }
    .quiz-footer-secondary {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .quiz-footer-secondary #quit-quiz-btn,
    .quiz-footer-secondary #review-quiz-btn {
        flex: 1;
        height: 38px;
        font-size: 12.5px;
        padding: 6px 8px;
        justify-content: center;
    }

    /* 4. Selection / Setup Screen */
    .mode-toggle-group {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .mode-toggle-btn {
        padding: 10px 8px;
        gap: 8px;
    }
    .mode-icon {
        font-size: 20px;
    }
    .mode-label {
        font-size: 13px;
    }
    .mode-desc {
        display: none;
    }

    .selection-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .tab-btn {
        padding: 10px 8px;
        font-size: 13.5px;
        justify-content: center;
    }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 20px;
    }
    .mode-card {
        padding: 12px 10px;
    }
    .card-icon {
        font-size: 24px;
        margin-bottom: 4px;
    }
    .card-title {
        font-size: 14.5px;
        margin-bottom: 4px;
    }
    .card-desc {
        font-size: 11px;
        line-height: 1.45;
        margin-bottom: 8px;
    }
    .card-meta {
        font-size: 10.5px;
        margin-bottom: 8px;
    }
    .card-action-btn {
        padding: 6px;
        font-size: 11px;
    }

    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 20px;
    }
    .category-card {
        padding: 10px 6px;
    }
    .category-card-icon {
        font-size: 24px;
        margin-bottom: 4px;
    }
    .category-card-title {
        font-size: 13px;
        margin-bottom: 2px;
    }
    .category-card-count {
        font-size: 10px;
    }

    .setup-summary-bar {
        bottom: 74px;
        padding: 10px 14px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
        border-radius: var(--radius-md);
    }
    .setup-summary-bar .summary-info {
        text-align: center;
    }
    .summary-text {
        font-size: 14px;
    }
    #launch-quiz-btn {
        width: 100%;
        height: 48px;
        font-size: 16px;
        font-weight: 800;
        justify-content: center;
        border-radius: var(--radius-md);
    }

    /* 5. Results Screen */
    .results-dashboard-grid {
        padding: 16px 12px;
        gap: 16px;
        margin: 16px 0;
    }
    .radial-container {
        width: 120px;
        height: 120px;
    }
    .radial-percent {
        font-size: 26px;
    }
    .radial-score-txt {
        font-size: 12px;
    }
    .details-row {
        padding: 6px 8px;
        font-size: 12.5px;
    }
    .results-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    .results-actions .btn {
        width: 100%;
        height: 48px;
        font-size: 15px;
        font-weight: 700;
        justify-content: center;
    }

    /* 6. Landing Screen Quick Nav */
    .landing-quick-nav-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .quick-nav-card {
        padding: 10px 8px;
        gap: 8px;
    }
    .nav-card-icon {
        font-size: 22px;
    }
    .nav-card-info h4 {
        font-size: 13px;
    }
    .nav-card-info p {
        font-size: 10.5px;
    }

    /* 7. Modals */
    .modal-card {
        width: 95%;
        max-height: 86vh;
        margin: 12px auto;
        border-radius: 16px;
    }
    .modal-header {
        padding: 12px 14px;
    }
    .modal-title {
        font-size: 15px;
    }
    .modal-body-scroll {
        padding: 12px 14px;
    }
    .feedback-actions {
        flex-direction: column;
        width: 100%;
    }
    .feedback-actions .btn {
        width: 100%;
        height: 46px;
        justify-content: center;
    }

    /* Existing Mobile Feature Adjustments */
    .leaderboard-table-header,
    .leaderboard-row {
        grid-template-columns: 45px 1.2fr 0.8fr 1fr;
    }
    .leaderboard-table-header .col-xp,
    .leaderboard-row .col-xp,
    .leaderboard-table-header .col-date,
    .leaderboard-row .col-date {
        display: none;
    }
    .leaderboard-podium {
        grid-template-columns: 1fr;
    }
    .podium-slot.rank-1 { order: 1; min-height: auto; }
    .podium-slot.rank-2 { order: 2; min-height: auto; }
    .podium-slot.rank-3 { order: 3; min-height: auto; }
    .share-modal-actions-grid {
        grid-template-columns: 1fr;
    }
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

/* Reduced Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
