RewriteEngine On
RewriteBase /

# Admin panel access
RewriteRule ^admin/?$ admin/index.php [L,QSA]
RewriteRule ^admin/([a-zA-Z0-9_-]+)/?$ admin/$1.php [L,QSA]

# User pages
RewriteRule ^login/?$ index.php [L,QSA]
RewriteRule ^register/?$ index.php?action=register [L,QSA]
RewriteRule ^dashboard/?$ dashboard.php [L,QSA]
RewriteRule ^wallet/?$ wallet.php [L,QSA]
RewriteRule ^deposit/?$ deposit.php [L,QSA]
RewriteRule ^withdraw/?$ withdraw.php [L,QSA]
RewriteRule ^profile/?$ profile.php [L,QSA]
RewriteRule ^referral/?$ referral.php [L,QSA]
RewriteRule ^game/?$ game.php [L,QSA]
RewriteRule ^history/?$ history.php [L,QSA]

# Security - protect sensitive files
<FilesMatch "\.(php|inc|sql|log|txt)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

<FilesMatch "^(index|config|db|auth)\.php$">
    Allow from all
</FilesMatch>

# Prevent directory listing
Options -Indexes

# Compress files
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

# Cache control
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
</IfModule>