/* ============================================================
   RESET & CUSTOM PROPERTIES
   ============================================================ */

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

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #3730a3;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --success-bg: #d1fae5;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --bg-card-hover: #f3f4f6;
    --border: #e5e7eb;
    --border-focus: #4f46e5;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.14);
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-thaana: 'Noto Sans Thaana', 'MV Boli', serif;
    --transition: all 0.18s ease;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-ui);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================================
   SCREENS
   ============================================================ */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ============================================================
   HOME SCREEN
   ============================================================ */

#screen-home {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(145deg, #eef2ff 0%, #f9fafb 50%, #f0fdf4 100%);
}

.home-content {
    width: 100%;
    max-width: 520px;
    text-align: center;
    animation: fadeUp 0.4s ease;
}

.app-logo {
    font-size: 64px;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.app-title {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 36px;
}

.load-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.load-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--success-bg);
    border-radius: 100px;
    color: #065f46;
    font-size: 0.875rem;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    flex-shrink: 0;
}

.mode-selection {
    animation: fadeUp 0.3s ease;
}

.mode-selection h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.mode-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: var(--font-ui);
}

.mode-card:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mode-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.mode-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.mode-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ============================================================
   SCREEN HEADER
   ============================================================ */

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

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

.header-title h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-badge {
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
}

/* ============================================================
   QUIZ HEADER & TIMER
   ============================================================ */

.quiz-header {
    background: var(--primary);
    border-bottom: none;
}

.quiz-header h2 {
    color: white;
}

.quiz-header .progress-badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

.quiz-header .btn-icon {
    color: white;
    border-color: rgba(255,255,255,0.3);
}

.quiz-header .btn-icon:hover {
    background: rgba(255,255,255,0.15);
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 100px;
    padding: 6px 14px;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

.quiz-progress-bar-wrap {
    height: 4px;
    background: #ddd6fe;
    position: sticky;
    top: 57px;
    z-index: 9;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.4s ease;
}

/* ============================================================
   QUESTION LIST
   ============================================================ */

.question-list {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.q-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.25s ease both;
}

.q-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.q-card.answered-correct {
    border-color: var(--success);
    background: var(--success-bg);
}

.q-card.answered-wrong {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.q-card.answered-correct:hover,
.q-card.answered-wrong:hover {
    transform: none;
    cursor: default;
}

.q-card-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.answered-correct .q-card-number {
    background: var(--success);
    color: white;
}

.answered-wrong .q-card-number {
    background: var(--danger);
    color: white;
}

.q-card-text {
    flex: 1;
    min-width: 0;
}

.q-card-question {
    font-family: var(--font-thaana);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q-card-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.answered-correct .q-card-status {
    color: #065f46;
    font-weight: 600;
}

.answered-wrong .q-card-status {
    color: #991b1b;
    font-weight: 600;
}

.q-card-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.q-card:hover .q-card-arrow {
    transform: translateX(3px);
    color: var(--primary);
}

/* ============================================================
   OVERLAYS
   ============================================================ */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay.hidden {
    display: none;
}

.overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    animation: fadeIn 0.2s ease;
}

.overlay-card {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.25s ease;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 0;
}

.q-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.qa-section {
    padding: 20px 24px;
}

.section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.qa-text {
    font-family: var(--font-thaana);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 14px;
    text-align: right;
}

.audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    background: var(--primary-bg);
    border: 1px solid #c7d2fe;
    border-radius: 100px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-ui);
}

.audio-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.audio-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.audio-btn.playing {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    animation: pulse 1s infinite;
}

.qa-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.overlay-nav {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px 24px;
    gap: 12px;
}

/* ============================================================
   QUIZ OVERLAY
   ============================================================ */

.quiz-overlay-card {
    max-width: 600px;
}

.quiz-q-timer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--warning);
    font-variant-numeric: tabular-nums;
}

.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 8px 24px 24px;
}

.answer-btn {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    font-family: var(--font-thaana);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    direction: rtl;
    line-height: 1.6;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-bg);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.answer-btn.correct {
    border-color: var(--success);
    background: var(--success-bg);
    color: #065f46;
    animation: correctPop 0.3s ease;
}

.answer-btn.wrong {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: #991b1b;
    animation: shake 0.3s ease;
}

.answer-btn:disabled {
    cursor: not-allowed;
}

/* ============================================================
   RESULTS SCREEN
   ============================================================ */

#screen-results {
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(145deg, #f0fdf4 0%, #f9fafb 50%, #eef2ff 100%);
}

.results-content {
    width: 100%;
    max-width: 520px;
    text-align: center;
    animation: fadeUp 0.4s ease;
}

.results-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.results-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 28px;
}

.results-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.results-breakdown {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 28px;
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.breakdown-item:last-child {
    border-bottom: none;
}

.breakdown-status {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.breakdown-status.correct {
    background: var(--success-bg);
    color: var(--success);
}

.breakdown-status.wrong {
    background: var(--danger-bg);
    color: var(--danger);
}

.breakdown-text {
    flex: 1;
    min-width: 0;
}

.breakdown-q {
    font-family: var(--font-thaana);
    font-size: 0.9rem;
    direction: rtl;
    text-align: right;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breakdown-a {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.breakdown-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary-bg);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: var(--font-ui);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ============================================================
   THAANA / DHIVEHI TEXT
   ============================================================ */

.thaana {
    font-family: var(--font-thaana);
    direction: rtl;
    unicode-bidi: embed;
}

/* ============================================================
   UTILITY
   ============================================================ */

.hidden {
    display: none !important;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 480px) {
    .mode-cards {
        grid-template-columns: 1fr;
    }

    .answers-grid {
        grid-template-columns: 1fr;
    }

    .results-stats {
        grid-template-columns: 1fr;
    }

    .app-title {
        font-size: 1.8rem;
    }

    .overlay-card {
        max-height: 95vh;
    }

    .results-actions {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .qa-text {
        font-size: 1.3rem;
    }
}
