/* Premium Dark Navy & Gold Theme */
:root {
    --primary: #D4AF37; /* Champagne Gold */
    --primary-hover: #b8972e;
    --bg-main: #0A1128; /* Deep Navy */
    --bg-secondary: #1A233A; /* Lighter Navy */
    --text-main: #FDFBF7; /* Soft White */
    --text-muted: #94A3B8; /* Slate */
    --glass-bg: rgba(26, 35, 58, 0.6);
    --glass-border: rgba(212, 175, 55, 0.2);
    --success: #10B981;
    --danger: #EF4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Shapes for Luxury Feel */
.bg-shapes {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at top right, #1A233A, #0A1128);
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}
.shape-1 {
    top: -10%; left: -10%;
    width: 300px; height: 300px;
    background: var(--primary);
}
.shape-2 {
    bottom: -10%; right: -10%;
    width: 400px; height: 400px;
    background: var(--primary);
    opacity: 0.15;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    padding: 2rem;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.4s ease-out;
}
.screen.active {
    display: block;
}
#splash-screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Home Screen */
.logo-container {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 2rem;
}
.logo-icon {
    width: 60px; height: 60px;
    margin: 0 auto 1rem;
    color: var(--primary);
}
.logo-text {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--primary);
}
.tagline {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.hadith-card {
    padding: 2rem;
    text-align: center;
    margin-bottom: 3rem;
}
.arabic {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    line-height: 2.5;
    color: var(--primary);
    margin-bottom: 1rem;
}
.large-arabic {
    font-size: 25px;
}
.translation {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}
.source {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 2px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1.2rem;
    border-radius: 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}
.btn svg { width: 24px; height: 24px; }
.btn-primary {
    background: var(--primary);
    color: var(--bg-main);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
}

.btn-icon {
    background: transparent;
    color: var(--text-main);
    border: none;
    cursor: pointer;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.3s;
}
.btn-icon:hover {
    background: var(--glass-bg);
}

/* Menu Screen */
.menu-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}
.game-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}
.mode-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 0.5rem;
    width: 100%;
    text-align: center;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.mode-card:hover {
    transform: translateY(-5px);
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.mode-card:hover .mode-icon {
    transform: scale(1.1);
}
.mode-card:hover h3 {
    color: var(--primary);
}
.mode-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.mode-card.disabled:hover {
    transform: none; background: var(--glass-bg); border-color: var(--glass-border);
}
.mode-icon {
    color: var(--primary);
    width: 32px; height: 32px;
}
.mode-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    transition: color 0.2s;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.game-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
}
.score-pill {
    background: rgba(212, 175, 55, 0.2);
    color: var(--primary);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--primary);
}

.game-content {
    padding: 2rem;
    text-align: center;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 2rem;
}

.hint {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: 1px;
}

.options-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.btn-option {
    background: var(--glass-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.8rem 1rem;
    border-radius: 15px;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-option:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--primary);
}
.btn-option.correct {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.btn-option.wrong {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Utilities */
.hidden { display: none !important; }

/* Loader */
.loader {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--primary);
}
.loader.active {
    display: flex;
}
.spinner {
    width: 40px; height: 40px;
    border: 4px solid rgba(212, 175, 55, 0.2);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 1rem 2rem;
    border-radius: 30px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast.error {
    background: var(--danger);
}

/* Scope & Selection Screens */
.primary-scope {
    background: var(--primary) !important;
    color: var(--bg-main) !important;
    border: none;
}
.primary-scope .mode-icon, .primary-scope h3 {
    color: var(--bg-main) !important;
}

/* Scrollbar styling for lists */
.selection-grid::-webkit-scrollbar, .selection-list::-webkit-scrollbar {
    width: 6px;
}
.selection-grid::-webkit-scrollbar-thumb, .selection-list::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.4);
    border-radius: 10px;
}

/* Juz Grid */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 5px;
}
.grid-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 15px 0;
    text-align: center;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.grid-item:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--primary);
}

/* Surah List */
.selection-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 5px;
}
.list-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}
.list-item:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--primary);
}
.surah-number {
    background: rgba(212, 175, 55, 0.2);
    color: var(--primary);
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
}
.surah-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-left: 15px;
    text-align: left;
}
.surah-details span:first-child {
    font-weight: 600;
}
.surah-details span:last-child {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.surah-arabic {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    color: var(--primary);
}

/* Puzzle Mode */
.puzzle-box {
    min-height: 80px;
    background: rgba(26, 35, 58, 0.4);
    border: 2px dashed var(--primary);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    direction: rtl;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}
.puzzle-pieces {
    display: flex;
    flex-wrap: wrap;
    direction: rtl;
    gap: 10px;
    justify-content: center;
}
.puzzle-word {
    background: var(--glass-bg);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 10px 15px;
    border-radius: 8px;
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.puzzle-word:hover {
    background: rgba(212, 175, 55, 0.2);
}
.puzzle-word.used {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

/* Modal PIN */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 90%;
    padding: 30px 20px;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease;
    border-color: var(--danger) !important;
}

select {
    color: var(--primary) !important;
}

select option {
    background-color: var(--bg-main);
    color: var(--primary);
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(212, 175, 55, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
    }
}

.pulse {
    animation: pulse-glow 1.5s infinite;
}

/* Tab Buttons */
.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}
.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.tab-btn.active {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: bold;
}

/* Premium Select Styling */
.premium-select {
    width: 100%;
    padding: 14px 15px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: 1px solid var(--primary);
    font-size: 1rem;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.15);
    cursor: pointer;
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23d4af37%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
}
.premium-select:hover, .premium-select:focus {
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
    background-color: rgba(0, 0, 0, 0.6);
    border-color: #f1c40f;
}
.premium-select option {
    background: #1a1a2e;
    color: white;
    padding: 10px;
}

/* Responsive Arabic Fonts */
@media (min-width: 768px) {
    .arabic { font-size: 2.2rem; line-height: 2.8; }
    .surah-arabic { font-size: 1.8rem; }
    .large-arabic { font-size: 32px; }
}
@media (max-width: 767px) {
    .arabic, .surah-arabic, .large-arabic, 
    .hint, .btn, .btn-option { 
        font-size: 15px !important; 
    }
    .translation, .source {
        font-size: 12px !important;
    }
    .arabic { line-height: 2.2; }
}

/* 3D Book Page Turn Animation */
@keyframes bookTurnIn {
    0% { 
        opacity: 0; 
        transform: perspective(1200px) rotateY(90deg); 
        transform-origin: left center; 
    }
    100% { 
        opacity: 1; 
        transform: perspective(1200px) rotateY(0deg); 
        transform-origin: left center; 
    }
}
#home-screen.active {
    animation: bookTurnIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Zen Mode */
body.zen-mode { background: #0a0a0a !important; }
body.zen-mode .app-bg { opacity: 0.1; }
body.zen-mode .glass { background: transparent; border-color: transparent; box-shadow: none; }
body.zen-mode .game-header { opacity: 0.3; transition: opacity 0.3s; }
body.zen-mode .game-header:hover { opacity: 1; }
body.zen-mode .btn-option { background: rgba(255,255,255,0.05); }
