/* ============================================
   Quran Word Study - Styling
   ============================================ */

:root {
    --primary: #1a7a4c;
    --primary-dark: #145c39;
    --primary-light: #e8f5e9;
    --learned: #2e7d32;
    --learned-bg: #c8e6c9;
    --unlearned: #ff9800;
    --unlearned-bg: #fff3e0;
    --danger: #d32f2f;
    --bg: #fafbfc;
    --card-bg: #ffffff;
    --text: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: 0.2s ease;
    --sidebar-width: 320px;
    --header-height: 60px;
    --arabic-font-size: 1.3rem;
    --arabic-bold: 400;
    --trans-font-size: 0.78rem;
}

/* ---- DARK THEME ---- */
[data-theme="dark"] {
    --primary: #4caf50;
    --primary-dark: #388e3c;
    --primary-light: #1b3a1b;
    --learned: #66bb6a;
    --learned-bg: #1b3a1b;
    --unlearned: #ff9800;
    --unlearned-bg: #3e2723;
    --danger: #ef5350;
    --bg: #121212;
    --card-bg: #1e1e1e;
    --text: #e0e0e0;
    --text-secondary: #9e9e9e;
    --border: #333;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    color-scheme: dark;
}

[data-theme="dark"] .surah-item:hover {
    background: #2a2a2a;
}

[data-theme="dark"] .surah-number {
    background: #333;
    color: #ccc;
}

[data-theme="dark"] .surah-item.active {
    background: var(--primary-light);
}

[data-theme="dark"] .surah-item.active .surah-number {
    background: var(--primary);
    color: white;
}

[data-theme="dark"] .word-arabic {
    color: #ffffff;
}

[data-theme="dark"] .word-translation {
    color: #b0b0b0;
}

[data-theme="dark"] .word-transliteration {
    color: #888;
}

[data-theme="dark"] .ayah-card {
    border-color: #333;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0,0,0,0.7);
}

[data-theme="dark"] .modal-box {
    background: #1e1e1e;
}

[data-theme="dark"] .sidebar-search input {
    background: #2a2a2a;
    color: var(--text);
    border-color: #444;
}

[data-theme="dark"] .word-card.unlearned {
    #border-color: #444;
}

[data-theme="dark"] select {
    background: #2a2a2a;
    color: var(--text);
    border-color: #444;
}

/* ---- SEPIA THEME ---- */
[data-theme="sepia"] {
    --primary: #8b6f47;
    --primary-dark: #6d5838;
    --primary-light: #f0e6d3;
    --learned: #8b6f47;
    --learned-bg: #e8dcc8;
    --unlearned: #c97b3a;
    --unlearned-bg: #f5e6d3;
    --danger: #a04030;
    --bg: #f5f0e8;
    --card-bg: #fcf8f0;
    --text: #3e2e1a;
    --text-secondary: #7a6a50;
    --border: #d8cdb8;
    --shadow: 0 1px 3px rgba(62,46,26,0.08);
    --shadow-md: 0 4px 12px rgba(62,46,26,0.12);
}

[data-theme="sepia"] .word-arabic {
    color: #3e2e1a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- HEADER ---- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
}

.header-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    letter-spacing: -0.3px;
}

.header-spacer { flex: 1; }

.header-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.progress-bar-wrap {
    width: 180px;
    height: 8px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #43a047);
    border-radius: 10px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

/* ---- TOGGLE SWITCH ---- */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    cursor: pointer;
    transition: background var(--transition);
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

/* ---- LAYOUT ---- */
.app-container {
    display: flex;
    height: calc(100vh - var(--header-height));
}

/* ---- SIDEBAR ---- */
.sidebar {
    width: var(--sidebar-width, 320px);
    min-width: var(--sidebar-width, 320px);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.sidebar.level-slim .surah-name,
.sidebar.level-slim .surah-meta,
.sidebar.level-slim .surah-progress-mini {
    display: none;
}

.sidebar.level-slim .surah-number {
    margin: 0 auto;
}

.sidebar.level-slim .surah-item {
    justify-content: center;
    padding: 8px 4px;
    margin-left: 14px;
}

.sidebar-toggle {
    font-size: 1.1rem;
    padding: 4px 10px;
    line-height: 1;
}

.sidebar-search {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 2;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    transition: border var(--transition);
}

.sidebar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,122,76,0.15);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
}

.surah-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background var(--transition);
    gap: 10px;
}

.surah-item:hover {
    background: #f8f9fa;
}

.surah-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.surah-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.surah-item.active .surah-number {
    background: var(--primary);
    color: white;
}

.surah-info {
    flex: 1;
    min-width: 0;
}

.surah-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.surah-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}

.surah-progress-mini {
    flex-shrink: 0;
}

.mini-circle {
    width: 36px;
    height: 36px;
}

.mini-circle-bg {
    fill: none;
    stroke: #e9ecef;
    stroke-width: 3;
}

.mini-circle-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
}

.surah-item.not-loaded {
    opacity: 0.7;
}

.surah-item.not-loaded:hover {
    background: #fff8e1;
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

/* ---- WELCOME / EMPTY STATE ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text);
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* ---- SURAH HEADER ---- */
.surah-header {
    text-align: center;
    margin-bottom: 28px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.surah-header .arabic-name {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    direction: rtl;
}

.surah-header .latin-name {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.surah-header .translated-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.surah-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ---- BUTTONS ---- */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
    background: var(--card-bg);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: #f8f9fa;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #ffebee;
}

/* ---- AYAH CARD ---- */
.ayah-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    position: relative;
}

.ayah-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.ayah-number-badge {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.ayah-words {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    direction: rtl;
}

/* ---- WORD CARD ---- */
.word-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
    min-width: 70px;
    position: relative;
    user-select: none;
}

.word-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.word-card.learned {
    background: var(--learned-bg);
    border-color: var(--learned);
}

.word-card.unlearned {
    background: var(--card-bg);
    border-color: #e0e0e0;
}

.word-card.unlearned:hover {
    border-color: var(--unlearned);
}

.word-arabic {
    font-size: var(--arabic-font-size, 1.3rem);
    font-weight: var(--arabic-bold, 400);
    color: #1a1a1a;
    line-height: 1.8;
    direction: rtl;
}

.word-translation {
    font-size: var(--trans-font-size, 0.78rem);
    color: var(--text-secondary);
    margin-top: 2px;
    text-align: center;
    direction: ltr;
    word-wrap: break-word;
    max-width: 120px;
}

.word-translation.hidden {
    display: none;
}

.word-card.learned .word-translation.hidden-by-toggle {
    display: none;
}

.word-transliteration {
    font-size: var(--trans-font-size, 0.78rem);
    color: #999;
    font-style: italic;
    direction: ltr;
}

.word-grammar {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    justify-content: center;
    flex-wrap: wrap;
}

.word-root {
    font-size: 0.65rem;
    font-weight: 700;
    color: #8e24aa;
    background: #f3e5f5;
    padding: 1px 5px;
    border-radius: 3px;
    direction: ltr;
}

.word-pos {
    font-size: 0.65rem;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    padding: 1px 5px;
    border-radius: 3px;
}

[data-theme="dark"] .word-root {
    color: #ce93d8;
    background: #4a148c;
}
[data-theme="dark"] .word-pos {
    color: #90caf9;
    background: #1a237e;
}

.word-learned-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: var(--learned);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
}

/* ---- LOADING ---- */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e9ecef;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- TOAST ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: #333;
    color: white;
    border-radius: var(--radius);
    font-size: 0.9rem;
    z-index: 999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---- STATS ---- */
.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        transition: max-height 0.25s ease;
    }

    .sidebar.level-slim {
        max-height: 80px;
    }

    .sidebar.level-slim .surah-name,
    .sidebar.level-slim .surah-meta,
    .sidebar.level-slim .surah-progress-mini {
        display: none;
    }

    .header {
        padding: 0 12px;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-height);
    }

    .options-separator {
        display: none;
    }

    .settings-slider {
        width: 50px;
    }

    .header-progress {
        width: 100%;
        justify-content: center;
        padding: 4px 0;
    }

    .progress-bar-wrap {
        width: 120px;
    }

    .options-group select {
        font-size: 0.7rem;
        padding: 2px 4px;
    }

    .header-brand {
        font-size: 1rem;
        white-space: nowrap;
    }

    .toggle-label {
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .toggle-switch {
        width: 36px;
        height: 22px;
        min-width: 36px;
    }

    .toggle-switch::after {
        width: 16px;
        height: 16px;
    }

    .progress-bar-wrap {
        width: 100px;
    }

    .main-content {
        padding: 12px;
    }

    .word-card {
        min-width: 55px;
        padding: 8px 5px;
    }

    .word-arabic {
        font-size: 1.1rem;
    }

    .surah-header .arabic-name {
        font-size: 1.8rem;
    }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ---- OPTIONS PANEL ---- */
.options-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.options-group select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: white;
    cursor: pointer;
    outline: none;
}

.options-group select:focus {
    border-color: var(--primary);
}

/* ---- NO BORDER ---- */
.word-card.no-border {
    border-color: transparent !important;
}

.word-card.no-border:hover {
    border-color: var(--primary) !important;
}

/* ---- ARABIC FONTS ---- */
:root,
[data-arabic-font="uthmani"] .word-arabic {
    font-family: 'Traditional Arabic', 'Scheherazade New', 'Amiri', serif;
}

[data-arabic-font="naskh"] .word-arabic {
    font-family: 'Noto Naskh Arabic', 'Traditional Arabic', serif;
}

[data-arabic-font="indopak"] .word-arabic {
    font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
}

[data-arabic-font="amiri"] .word-arabic {
    font-family: 'Amiri', 'Traditional Arabic', serif;
}

/* ---- OPTIONS SEPARATOR ---- */
.options-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

/* ---- FREQUENCY BADGE ---- */
.word-frequency {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-top: 3px;
    line-height: 1.4;
}

/* ---- SETTINGS SLIDER ---- */
.settings-slider-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.settings-slider-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.settings-slider {
    width: 60px;
    height: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

.settings-slider-value {
    font-size: 0.7rem;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* ---- ABOUT MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    background: none;
    border: none;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.modal-section {
    margin-bottom: 16px;
}

.modal-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.modal-section p,
.modal-section li {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.modal-section ul {
    padding-left: 18px;
}

.modal-license {
    font-size: 0.75rem;
    color: #999;
    font-style: italic;
    margin-top: 2px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ---- WORD EXPLORE BUTTON ---- */
.word-explore-btn {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 2;
    line-height: 1;
}

.word-card:hover .word-explore-btn {
    opacity: 1;
}

.word-explore-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* ---- EXPLORER MODAL ---- */
.explorer-scope-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.explorer-scope-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    transition: all 0.15s;
}

.explorer-scope-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.explorer-scope-btn:hover:not(.active) {
    background: var(--primary-light);
}

.explorer-surah-group {
    margin-bottom: 12px;
}

.explorer-surah-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.explorer-word {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.explorer-word:hover {
    background: var(--primary-light);
}

.explorer-word.learned {
    background: var(--learned-bg);
}

.explorer-ayah {
    min-width: 100px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.explorer-arabic {
    font-size: 1.1rem;
    min-width: 60px;
    text-align: center;
}

.explorer-trans {
    color: var(--text-secondary);
    flex: 1;
}

.explorer-check {
    font-size: 0.85rem;
}

/* ---- FREQUENCY MODAL ---- */
.freq-word {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.freq-word:hover {
    background: #f8f9fa;
}

.freq-word.learned {
    background: var(--learned-bg);
}

.freq-arabic {
    font-size: 1.1rem;
    min-width: 70px;
    text-align: center;
}

.freq-trans {
    color: var(--text-secondary);
    flex: 1;
    font-size: 0.8rem;
}

.freq-count {
    font-weight: 700;
    font-size: 0.8rem;
    min-width: 40px;
    text-align: right;
}

.freq-count-in-surah {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--primary);
    min-width: 36px;
    text-align: right;
}

.freq-learned {
    font-size: 0.9rem;
    min-width: 24px;
    text-align: center;
}

.freq-explore-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
}

.freq-explore-btn:hover {
    background: var(--primary-light);
}

/* ---- QUIZ ---- */
.quiz-question {
    text-align: center;
    padding: 20px 10px;
}

.quiz-translation {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.quiz-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 10px 20px;
}

.quiz-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    background: var(--card-bg);
}

.quiz-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateX(4px);
}

.quiz-option.correct {
    border-color: var(--learned);
    background: var(--learned-bg);
}

.quiz-option.wrong {
    border-color: var(--danger);
    background: #ffebee;
}

.quiz-option-arabic {
    font-size: 1.3rem;
    font-weight: 500;
}

.quiz-option-trans {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.quiz-progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 10px 20px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.quiz-result {
    text-align: center;
    padding: 30px 10px;
}

.quiz-result-emoji {
    font-size: 3rem;
    margin-bottom: 10px;
}

.quiz-result-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.quiz-result-pct {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.quiz-result-msg {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 20px;
}

/* ---- VIEW MODE BADGE ---- */
.mode-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}

/* ---- MUSHAF VIEW ---- */
.mushaf-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    gap: 6px;
}

.mushaf-page {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    direction: rtl;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: 6px;
    overflow-x: auto;
}

.mushaf-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: var(--mushaf-line-width, 1px) solid var(--mushaf-line-color, #f0f0f0);
    direction: rtl;
    gap: 4px;
}

.mushaf-line.center {
    justify-content: center;
}

.mushaf-line.bsml-line {
    justify-content: center !important;
    font-size: 1.2rem;
    text-align: center;
}

.mushaf-line.bsml-line .mushaf-word-w {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
}

.mushaf-line.bsml-line .mushaf-word-w .mushaf-word {
    margin: 0 auto;
}

.mushaf-line.basmalah-line {
    justify-content: center !important;
}

.mushaf-word {
    font-size: var(--arabic-font-size, 1.6rem);
    font-weight: var(--arabic-bold, 500);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 2;
    display: inline;
}

.mushaf-word-w {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    margin: 0 2px;
    position: relative;
}

.mushaf-sub {
    display: block;
    font-size: var(--trans-font-size, 0.6rem);
    line-height: 1.3;
    direction: ltr;
    text-align: center;
    max-width: 80px;
    word-wrap: break-word;
    margin: 0 auto;
}

.mushaf-sub.translation {
    color: var(--text-secondary);
}

.mushaf-sub.transliteration {
    color: #999;
    font-style: italic;
}

.mushaf-sub.grammar {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.mushaf-sub.hidden-by-toggle {
    display: none;
}

.mushaf-sub.frequency {
    font-size: 0.6rem;
    font-weight: 700;
}

.mushaf-sub.trans-diagonal {
    display: inline-block;
    transform: rotate(-12deg);
    transform-origin: left center;
    font-style: italic;
    opacity: 0.85;
}

.mushaf-sub.trans-vertical {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    writing-mode: sideways-lr;
    font-size: 0.6rem;
    line-height: 1.2;
    opacity: 0.8;
}

.mushaf-learned-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--learned);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: white;
    line-height: 1;
}

.mushaf-word.learned {
    color: var(--learned);
}

.mushaf-word.learned {
    color: var(--learned);
}

/* Dark theme fixes for Mushaf */
[data-theme="dark"] .mushaf-word {
    color: #fff;
}
[data-theme="dark"] .mushaf-word.learned {
    color: #66bb6a;
}

/* ---- MUSHAF WORD INFO POPUP ---- */
.mushaf-info {
    display: none;
    position: absolute;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    min-width: 180px;
    max-width: 260px;
}

.mushaf-info.show {
    display: block;
}

.mushaf-info-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.mushaf-info-arabic {
    font-size: 1.6rem;
    font-weight: 600;
    direction: rtl;
    line-height: 1.4;
}

.mushaf-info-trans {
    font-size: 0.9rem;
    color: var(--text);
}

.mushaf-info-transliteration {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
}

.mushaf-info-grammar {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin: 2px 0;
}

.mushaf-page {
    position: relative;
}

/* ---- SETTINGS PANEL ---- */
.tafsir-tabs {
    display: inline-flex;
    gap: 2px;
}

.tafsir-tab {
    padding: 2px 8px;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
}

.tafsir-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,0.3);
}

.settings-overlay.show {
    display: block;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: -360px;
    width: 340px;
    height: 100%;
    background: var(--card-bg);
    z-index: 9999;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.settings-overlay.show .settings-panel {
    right: 0;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.settings-body {
    padding: 12px 20px 20px;
    flex: 1;
    overflow-y: auto;
}

.settings-group {
    margin-bottom: 16px;
}

.settings-group-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.9rem;
    gap: 8px;
}

.settings-item select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    background: var(--card-bg);
}

.settings-item input[type="range"] {
    width: 80px;
    accent-color: var(--primary);
}

/* ==================== HANGMAN ==================== */
.hangman-key {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Scheherazade New', 'Amiri', serif;
    line-height: 36px;
    text-align: center;
    padding: 0;
}
.hangman-key:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
}
.hangman-key:disabled {
    opacity: 0.4;
    cursor: default;
}
.hangman-key.key-correct {
    background: var(--learned-bg);
    border-color: var(--learned);
    color: var(--learned);
}
.hangman-key.key-wrong {
    background: #fce4ec;
    border-color: var(--danger);
    color: var(--danger);
}

[data-theme="dark"] .hangman-key.key-correct {
    background: #1b3a1b;
}
[data-theme="dark"] .hangman-key.key-wrong {
    background: #3e2723;
}

/* ==================== CHILD-FRIENDLY THEMES ==================== */
[data-theme="kids"] {
    --primary: #ff6b6b;
    --primary-dark: #ff5252;
    --primary-light: #ffe0e0;
    --learned: #4caf50;
    --learned-bg: #e8f5e9;
    --unlearned: #ffc107;
    --unlearned-bg: #fff8e1;
    --danger: #f44336;
    --bg: #fff9c4;
    --card-bg: #ffffff;
    --text: #212529;
    --text-secondary: #666;
    --border: #ffd54f;
    --shadow: 0 4px 12px rgba(255,193,7,0.2);
    --shadow-md: 0 8px 24px rgba(255,193,7,0.3);
    --arabic-font-size: 1.4rem;
    --trans-font-size: 0.8rem;
}

[data-theme="kids"] .word-card {
    background: linear-gradient(135deg, #fff9c4 0%, #ffeb3b 100%);
    border: 2px solid #ffd54f;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(255,193,7,0.3);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="kids"] .word-card:hover {
    transform: scale(1.1) rotate(2deg);
    box-shadow: 0 8px 20px rgba(255,193,7,0.4);
}

[data-theme="kids"] .word-card.learned {
    background: linear-gradient(135deg, #c8e6c9 0%, #81c784 100%);
    border-color: #4caf50;
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

[data-theme="kids"] .word-card.unlearned {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe082 100%);
    border-color: #ffc107;
}

[data-theme="kids"] .quiz-option {
    background: linear-gradient(135deg, #e3f2fd 0%, #90caf9 100%);
    border: 2px solid #64b5f6;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

[data-theme="kids"] .quiz-option:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 16px rgba(100,181,246,0.4);
}

[data-theme="kids"] .btn {
    background: linear-gradient(135deg, #ffecb3 0%, #ffd54f 100%);
    border: 2px solid #ffc107;
    border-radius: 8px;
    color: #333;
    font-weight: 700;
    transition: all 0.2s;
}

[data-theme="kids"] .btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255,193,7,0.4);
}

[data-theme="kids"] .btn-primary {
    background: linear-gradient(135deg, #ff8a80 0%, #ff5722 100%);
    border-color: #ff5722;
    color: white;
}

/* ==================== GAME ENHANCEMENTS CSS ==================== */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes sparkle {
    0% { transform: scale(0) rotate(0deg); opacity: 0; }
    50% { transform: scale(1) rotate(180deg); opacity: 1; }
    100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

@keyframes confetti {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(-100px) rotate(720deg); opacity: 0; }
}

.game-achievement {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #fff 0%, #f0f0f0 100%);
    border: 3px solid #ffd700;
    border-radius: 20px;
    padding: 30px 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    z-index: 10000;
    text-align: center;
    animation: bounce 0.6s ease-out;
}

.game-achievement h3 {
    font-size: 2rem;
    color: #ffd700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.game-achievement p {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 20px;
}

.game-streak-indicator {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    animation: pulse 2s infinite;
    margin-left: 8px;
}

.game-points-indicator {
    display: inline-block;
    background: linear-gradient(135deg, #4caf50 0%, #8bc34a 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-left: 8px;
}

.game-level-indicator {
    display: inline-block;
    background: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-left: 8px;
}

.motivational-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    animation: pulse 1s infinite;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #ffd700;
    animation: confetti 2s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

.star-particle {
    position: fixed;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #ffd700 0%, transparent 70%);
    border-radius: 50%;
    animation: sparkle 1s ease-out forwards;
    pointer-events: none;
    z-index: 9999;
}

/* ==================== ENHANCED GAME BUTTONS ==================== */
.game-mode-btn {
    position: relative;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.game-mode-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.game-mode-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.game-mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.game-mode-btn:hover::before {
    left: 100%;
}

/* ==================== ENHANCED MODAL STYLES ==================== */
[data-theme="kids"] .modal-box {
    background: linear-gradient(135deg, #ffffff 0%, #fff9c4 100%);
    border: 4px solid #ffd54f;
    box-shadow: 0 20px 60px rgba(255,193,7,0.4);
}

[data-theme="kids"] .modal-title {
    color: #ff6b6b;
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 20px;
}

[data-theme="kids"] .modal-subtitle {
    color: #666;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 30px;
}

/* ==================== RESPONSIVE GAME STYLES ==================== */
@media (max-width: 768px) {
    .game-mode-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .game-streak-indicator,
    .game-points-indicator,
    .game-level-indicator {
        font-size: 0.8rem;
        padding: 3px 8px;
    }
}

/* ==================== POINTS FLOAT ANIMATION ==================== */
@keyframes pointsFloat {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}

/* ==================== SHAKE ANIMATION (WRONG ANSWER) ==================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ==================== DARK THEME FIXES FOR GAMES ==================== */
[data-theme="dark"] .quiz-option {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .quiz-option:hover {
    background: #3a3a3a;
}

[data-theme="dark"] .quiz-option.correct {
    background: #1b3a1b;
    border-color: #4caf50;
}

[data-theme="dark"] .quiz-option.wrong {
    background: #3e2723;
    border-color: #f44336;
}

/* ==================== SEPIA THEME FIXES FOR GAMES ==================== */
[data-theme="sepia"] .quiz-option {
    background: #f5e6d3;
    border-color: #d8cdb8;
}

[data-theme="sepia"] .quiz-option:hover {
    background: #e8dcc8;
}
