/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    direction: ltr;
    padding-top: 70px; /* Space for mobile fixed header */
}

/* Arabic text styling */
.arabic-text {
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 2;
    font-size: 1.2rem;
}

.arabic-input {
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    direction: rtl;
    text-align: right;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Fixed Header - Desktop */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 12px 0;
    width: 100%;
}

/* Desktop header styling */
@media (min-width: 769px) {
    body {
        padding-top: 90px; /* Space for floating fixed header */
    }
    
    .header {
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 1200px;
        border-radius: 12px;
    }

    /* Reduce space above the main title slightly on desktop */
    .main-title {
        margin: 40px 0 25px 0; /* Previously 60px top margin */
    }
    
    /* Show desktop navigation, hide mobile elements */
    .desktop-nav,
    .desktop-social {
        display: flex;
    }
    
    .hamburger-btn {
        display: none;
    }
    
    /* Hide mobile menu on desktop */
    .mobile-menu,
    .mobile-menu-overlay {
        display: none;
    }
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

/* Main Title Outside Header */
.main-title {
    text-align: center;
    margin: 60px 0 25px 0;
    padding: 0 20px;
}

.main-title h1 {
    font-size: 2.53rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    line-height: 1.3;
}

/* Navigation Menu */
.navbar {
    flex: 1;
}

.navbar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
}

.navbar ul li {
    margin: 0;
}

.navbar ul li a {
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 1.08rem;
    font-weight: bold;
    transition: all 0.3s ease;
    display: block;
    white-space: nowrap;
    background-color: transparent;
}

.navbar ul li a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.navbar ul li a.active {
    background-color: transparent;
}

.navbar ul li a.active:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Header Social Links - Top Right */
.header-social-links {
    display: flex;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.header-social-links a {
    color: white;
    font-size: 1.33rem;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 6px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-social-links a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.header-social-links .YouTube:hover { color: #FF0000; }
.header-social-links .facebook:hover { color: #4267B2; }
.header-social-links .instagram:hover { color: #E4405F; }
.header-social-links .TikTok:hover { color: #000000; }

/* Hamburger Button - Hidden on Desktop */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.hamburger-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Menu Styles */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 1001;
    transition: left 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.mobile-menu.active {
    left: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-menu-header h3 {
    color: white;
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.mobile-menu-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.mobile-menu-links {
    list-style: none;
    padding: 20px 0;
    margin: 0;
    flex: 1;
}

.mobile-menu-links li {
    margin: 0;
}

.mobile-menu-links a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    font-size: 1.1rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.mobile-menu-links a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    padding-left: 30px;
}

.mobile-menu-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-menu-social a {
    color: white;
    font-size: 1.5rem;
    padding: 10px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
}

.mobile-menu-social a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.mobile-menu-social .YouTube:hover { color: #FF0000; }
.mobile-menu-social .facebook:hover { color: #4267B2; }
.mobile-menu-social .instagram:hover { color: #E4405F; }
.mobile-menu-social .TikTok:hover { color: #000000; }


/* Test Area */
.test-area {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    position: relative; /* For positioning onboarding arrows */
}

.text-display-container {
    margin-bottom: 20px;
}

/* Integrated Test Controls */
.integrated-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid #e1e8ed;
    position: relative;
    overflow: hidden;
    gap: 20px;
}

.integrated-controls::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.05), transparent);
    transition: left 0.6s;
}

.integrated-controls:hover::before {
    left: 100%;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
}

.control-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
    min-width: fit-content;
}

.control-item label i {
    font-size: 0.9rem;
    color: #667eea;
    opacity: 0.8;
}

.control-item label span {
    font-weight: 600;
}

.modern-select {
    padding: 8px 14px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #2c3e50;
    background: white;
    min-width: 130px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23667eea" d="m0 1 2 2 2-2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px;
}

.modern-select:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.modern-select:focus {
    outline: none;
    border-color: #667eea;
    background-color: #f8f9ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modern-select:active {
    transform: translateY(0);
}

.text-display {
    background: #f8f9fa;
    padding: 35px;
    border-radius: 8px;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.40; /* Updated line spacing */
    margin-bottom: 20px;
    border: 3px solid #e1e8ed;
    min-height: 200px;
    color: #2c3e50;
    position: relative;
    letter-spacing: 0.5px;
    text-align: justify; /* Justified text */
}

.text-display.arabic-text {
    border-right: 4px solid #667eea;
    border-left: none;
}

/* Text-to-Speech Button */
.tts-button {
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex !important; /* Force display */
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    z-index: 100; /* Higher z-index to ensure visibility */
    opacity: 0.8;
    visibility: visible !important; /* Ensure visibility */
}

.tts-button:hover {
    opacity: 1;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.tts-button:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.tts-button:focus {
    outline: none;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4), 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* TTS Button States */
.tts-button.speaking {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    animation: pulse-speaking 1.5s infinite;
}

.tts-button.speaking .bi-mic-fill:before {
    content: "\f3c6"; /* Changes to volume up icon when speaking */
}

.tts-button.error {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    animation: shake 0.5s ease-in-out;
}

@keyframes pulse-speaking {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 6px 20px rgba(40, 167, 69, 0.5);
        transform: scale(1.05);
    }
}

/* Red pulsing animation for stop state */
@keyframes pulse-stop {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 6px 20px rgba(220, 53, 69, 0.7);
        transform: scale(1.08);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Text highlighting for real-time feedback - Preserves Arabic connections */
.text-display .text-segment {
    position: relative;
    display: inline;
}

.text-display .text-segment.correct {
    background-color: rgba(212, 237, 218, 0.6);
    color: #155724;
    box-shadow: 0 2px 4px rgba(21, 87, 36, 0.1);
}

.text-display .text-segment.incorrect {
    background-color: rgba(248, 215, 218, 0.7);
    color: #721c24;
    text-decoration: underline wavy #dc3545;
    text-underline-offset: 3px;
    box-shadow: 0 2px 4px rgba(114, 28, 36, 0.1);
}

.text-display .text-segment.current {
    background-color: rgba(0, 123, 255, 0.8);
    color: white;
    animation: currentBlink 1s infinite;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.3);
}

.text-display .text-segment.pending {
    color: #6c757d;
    opacity: 0.8;
}

/* Character-level highlighting for Arabic text - optimized for Arabic script */
.text-display .text-char {
    /* Use inline display to preserve text flow and Arabic shaping */
    display: inline;
    /* No positioning, padding, margin, or border to avoid disrupting connections */
    position: static;
    font-synthesis: none;
    /* Ensure Arabic text shaping is preserved */
    text-rendering: optimizeSpeed;
}

.text-display .text-char.correct {
    background: linear-gradient(to bottom, rgba(212, 237, 218, 0.3) 0%, rgba(212, 237, 218, 0.6) 100%);
    color: #155724;
    /* Use text-shadow instead of box-shadow to avoid layout disruption */
    text-shadow: 0 0 2px rgba(21, 87, 36, 0.3);
}

.text-display .text-char.incorrect {
    background: linear-gradient(to bottom, rgba(248, 215, 218, 0.4) 0%, rgba(248, 215, 218, 0.8) 100%);
    color: #721c24;
    /* Use text-shadow for the error indication */
    text-shadow: 0 0 3px rgba(220, 53, 69, 0.5);
    /* Subtle underline effect using box-shadow positioned below */
    box-shadow: inset 0 -2px 0 0 rgba(220, 53, 69, 0.6);
}

.text-display .text-char.current {
    background: linear-gradient(to bottom, rgba(0, 123, 255, 0.6) 0%, rgba(0, 123, 255, 0.9) 100%);
    color: white;
    animation: currentBlink 1s infinite;
    text-shadow: 0 0 4px rgba(0, 123, 255, 0.8);
    /* No border-radius to preserve Arabic connections */
}

.text-display .text-char.pending {
    color: #6c757d;
    opacity: 0.8;
}

@keyframes currentBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.7; }
}

/* Ensure Arabic text flows naturally with highlighting */
.text-display .text-content {
    direction: rtl;
    text-align: right;
    unicode-bidi: embed;
    /* Let browser handle natural Arabic script connections */
    text-rendering: optimizeSpeed;
    -webkit-text-size-adjust: 100%;
    font-kerning: auto;
    font-variant-ligatures: normal;
    /* Remove explicit font-feature-settings to allow natural rendering */
}

/* Progress Bar - Enhanced */
.progress-bar {
    width: 100%;
    height: 24px;
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 
        inset 0 3px 6px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #dee2e6;
    margin-bottom: 12px;
    position: relative;
    animation: progressBarGlow 3s ease-in-out infinite alternate;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
    border-radius: 15px 15px 0 0;
    animation: progressHighlight 2s ease-in-out infinite;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 30%, #17a2b8 70%, #007bff 100%);
    border-radius: 15px;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 0%;
    position: absolute;
    right: 0;
    top: 0;
    box-shadow: 
        0 3px 12px rgba(40, 167, 69, 0.4),
        inset 0 1px 3px rgba(255, 255, 255, 0.3);
    animation: progressFlow 3s ease-in-out infinite;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
    border-radius: 15px;
    animation: progressShine 2.5s ease-in-out infinite;
}

/* Progress bar urgency states - Enhanced */
.progress-fill.urgent {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 30%, #bd2130 70%, #a71e2a 100%) !important;
    box-shadow: 
        0 4px 16px rgba(220, 53, 69, 0.6) !important,
        inset 0 1px 3px rgba(255, 255, 255, 0.2) !important;
    animation: urgentPulse 0.8s ease-in-out infinite alternate !important;
}

.progress-fill.warning {
    background: linear-gradient(135deg, #fd7e14 0%, #f39c12 50%, #e67e22 100%) !important;
    box-shadow: 
        0 3px 14px rgba(253, 126, 20, 0.5) !important,
        inset 0 1px 3px rgba(255, 255, 255, 0.3) !important;
    animation: warningPulse 1.2s ease-in-out infinite alternate !important;
}

.progress-fill.low-time {
    background: linear-gradient(135deg, #ffc107 0%, #f1c40f 50%, #f39c12 100%) !important;
    box-shadow: 
        0 2px 12px rgba(255, 193, 7, 0.5) !important,
        inset 0 1px 3px rgba(255, 255, 255, 0.4) !important;
    animation: lowTimePulse 1.5s ease-in-out infinite alternate !important;
}

.progress-fill.paused {
    background: linear-gradient(135deg, #6c757d 0%, #495057 50%, #343a40 100%) !important;
    box-shadow: 
        0 2px 10px rgba(108, 117, 125, 0.4) !important,
        inset 0 1px 3px rgba(255, 255, 255, 0.1) !important;
    animation: pausedPulse 2s ease-in-out infinite alternate !important;
}

/* Enhanced Progress Bar Animations */
@keyframes progressBarGlow {
    0% { box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1); }
    100% { box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 12px rgba(102, 126, 234, 0.3); }
}

@keyframes progressHighlight {
    0%, 100% { opacity: 0.6; transform: translateX(-100%); }
    50% { opacity: 1; transform: translateX(0%); }
}

@keyframes progressFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes progressShine {
    0% { transform: translateX(-100%) skewX(-15deg); opacity: 0; }
    50% { transform: translateX(0%) skewX(-15deg); opacity: 1; }
    100% { transform: translateX(100%) skewX(-15deg); opacity: 0; }
}

@keyframes urgentPulse {
    0% {
        box-shadow: 
            0 4px 16px rgba(220, 53, 69, 0.4),
            inset 0 1px 3px rgba(255, 255, 255, 0.2);
        filter: brightness(1) saturate(1);
        transform: scale(1);
    }
    100% {
        box-shadow: 
            0 6px 24px rgba(220, 53, 69, 0.8),
            inset 0 1px 3px rgba(255, 255, 255, 0.3);
        filter: brightness(1.15) saturate(1.1);
        transform: scale(1.01);
    }
}

@keyframes warningPulse {
    0% {
        box-shadow: 
            0 3px 14px rgba(253, 126, 20, 0.4),
            inset 0 1px 3px rgba(255, 255, 255, 0.3);
        filter: brightness(1);
    }
    100% {
        box-shadow: 
            0 4px 18px rgba(253, 126, 20, 0.6),
            inset 0 1px 3px rgba(255, 255, 255, 0.4);
        filter: brightness(1.1);
    }
}

@keyframes lowTimePulse {
    0% {
        box-shadow: 
            0 2px 12px rgba(255, 193, 7, 0.4),
            inset 0 1px 3px rgba(255, 255, 255, 0.4);
        filter: brightness(1);
    }
    100% {
        box-shadow: 
            0 3px 15px rgba(255, 193, 7, 0.6),
            inset 0 1px 3px rgba(255, 255, 255, 0.5);
        filter: brightness(1.08);
    }
}

@keyframes pausedPulse {
    0% {
        opacity: 0.8;
        filter: grayscale(0.2);
    }
    100% {
        opacity: 1;
        filter: grayscale(0);
    }
}

/* History Modal Styles */
.stats-summary {
    text-align: center;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.stats-summary h3 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e5e9;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: #495057;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.history-item {
    background: white;
    margin-bottom: 15px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e1e5e9;
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.history-date {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.history-rating {
    font-size: 0.9rem;
    padding: 4px 12px;
    border-radius: 20px;
    background: #e9ecef;
    color: #495057;
    font-weight: 600;
}

.history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
}

.history-stat {
    text-align: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.history-stat .stat-value {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: #495057;
    margin-bottom: 2px;
}

.history-stat .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 1.1rem;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px dashed #dee2e6;
    margin: 20px 0;
}

/* Dark mode styles for history modal */
body.dark-mode .stats-summary {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    border-color: #495057;
}

body.dark-mode .stats-summary h3 {
    color: #f8f9fa;
}

body.dark-mode .stat-card {
    background: #495057;
    border-color: #6c757d;
}

body.dark-mode .stat-card:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

body.dark-mode .stat-number {
    color: #f8f9fa;
}

body.dark-mode .stat-label {
    color: #adb5bd;
}

body.dark-mode .history-item {
    background: #495057;
    border-color: #6c757d;
}

body.dark-mode .history-item:hover {
    box-shadow: 0 4px 10px rgba(255, 255, 255, 0.1);
}

body.dark-mode .history-header {
    border-color: #6c757d;
}

body.dark-mode .history-date {
    color: #adb5bd;
}

body.dark-mode .history-rating {
    background: #6c757d;
    color: #f8f9fa;
}

body.dark-mode .history-stat {
    background: #6c757d;
    border-color: #495057;
}

body.dark-mode .history-stat .stat-value {
    color: #f8f9fa;
}

body.dark-mode .history-stat .stat-label {
    color: #adb5bd;
}

body.dark-mode .no-results {
    background: #495057;
    color: #adb5bd;
    border-color: #6c757d;
}

.typing-input-container {
    position: relative;
    margin-bottom: 20px;
}

.typing-input {
    width: 100%;
    min-height: 160px;
    padding: 25px;
    border: 3px solid #e1e8ed;
    border-radius: 8px;
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 2.2;
    resize: vertical;
    transition: all 0.3s ease;
    letter-spacing: 0.3px;
}

.typing-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.typing-input::placeholder {
    color: #888;
    font-weight: 500;
    opacity: 0.8;
}

/* Single Onboarding Arrow */
.onboarding-arrows {
    position: absolute;
    top: 70%; /* Position lower in the text box - middle-lower area */
    transform: translateY(-50%); /* Center precisely */
    left: -180px; /* Optimized position for 100% zoom visibility */
    z-index: 1000;
    pointer-events: none;
    animation: onboardingFadeIn 1s ease-out 1.5s both;
}

.onboarding-arrows.hidden {
    animation: onboardingFadeOut 0.5s ease-out both;
}

.onboarding-arrow.single-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    animation: slideFromLeft 1.5s ease-out 2s both;
}

.arrow-graphic {
    display: flex;
    align-items: center;
    position: relative;
}

.arrow-line {
    width: 150px; /* Even longer arrow line to reach closer to text box */
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    animation: arrowPulse 2.5s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.arrow-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: arrowShimmer 2s infinite;
}

.arrow-tip {
    width: 0;
    height: 0;
    animation: arrowTipPulse 2.5s ease-in-out infinite;
}

.right-pointing .arrow-tip {
    border-left: 16px solid #764ba2;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    margin-left: -2px;
}

.left-pointing .arrow-tip {
    border-right: 16px solid #764ba2;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    margin-right: -2px;
}

.arrow-text-above {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 25px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    animation: textFloat 3.5s ease-in-out infinite;
    text-align: center;
}

.arrow-text-above::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: textShimmer 3s infinite;
}

.guide-message-english {
    font-size: 1.1rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
}

/* Onboarding Animations */
@keyframes onboardingFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes onboardingFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes slideFromRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideFromLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes arrowPulse {
    0%, 100% {
        transform: scaleX(1);
        opacity: 1;
    }
    50% {
        transform: scaleX(1.1);
        opacity: 0.8;
    }
}

@keyframes arrowTipPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.9;
    }
}

@keyframes arrowShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes textFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes textShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.typing-input:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.test-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 1px solid #667eea;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: 1px solid #6c757d;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    border-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover:not(:disabled) {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.btn-download {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: 1px solid #28a745;
    position: relative;
    overflow: hidden;
}

.btn-download::before {
    content: "📸";
    margin-right: 8px;
}

.btn-download:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838 0%, #1ea47c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-download:active {
    transform: translateY(0);
}

.btn-social {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-social.facebook {
    background: #1877f2;
    color: white;
}

.btn-social.x-twitter {
    background: #000000;
    color: white;
    border: 1px solid #333;
}

.btn-social.x-twitter:hover {
    background: #1a1a1a;
    border-color: #555;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-social.whatsapp {
    background: #25d366;
    color: white;
}

/* Export button removed */

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Results Panel */
.results-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.results-panel h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    display: block;
}

/* Chart functionality removed for better performance */

/* Achievements Panel */
.achievements-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.achievements-panel h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5rem;
    text-align: center;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.achievement {
    display: flex;
    align-items: center;
    padding: 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.achievement.unlocked {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
}

.achievement.locked {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    opacity: 0.6;
}

.achievement-icon {
    font-size: 2rem;
    margin-right: 15px;
}

.achievement-info h4 {
    margin: 0 0 5px 0;
    color: #2c3e50;
}

.achievement-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #6c757d;
}

.achievement-title-arabic {
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    font-size: 0.9rem;
    color: #495057;
    margin: 2px 0 8px 0;
    font-weight: 500;
}

.achievement-desc-arabic {
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    font-size: 0.85rem;
    color: #6c757d;
    margin: 5px 0 0 0;
    direction: rtl;
    text-align: right;
}

.achievement-status {
    margin-left: auto;
    flex-shrink: 0;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unlocked-badge {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    animation: pulse 2s infinite;
}

.locked-badge {
    background: #e9ecef;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #fefefe;
    margin: 1% auto;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    max-width: 900px;
    max-height: 95vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    /* Ensure smooth scrolling for better screenshots */
    scroll-behavior: smooth;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    margin: 0;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #dee2e6;
    text-align: center;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Button groups in modal footer */
.social-buttons-group {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.action-buttons-group {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Responsive button groups */
@media (max-width: 768px) {
    .social-buttons-group,
    .action-buttons-group {
        gap: 8px;
    }
    
    .social-buttons-group {
        flex-direction: column;
        align-items: center;
    }
}

/* Results Styling */
.results-header {
    text-align: center;
    margin-bottom: 30px;
}

.results-score {
    font-size: 3rem;
    font-weight: bold;
    color: #667eea;
    margin: 10px 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.result-label {
    font-weight: 600;
    color: #2c3e50;
}

.result-value {
    font-weight: bold;
    color: #667eea;
}

/* Special styling for achievement score */
.achievement-score-item {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important;
    border-left-color: #f1c40f !important;
    border-left-width: 5px !important;
}

.achievement-score-item .result-label {
    color: #d68910;
    font-weight: 700;
}

.achievement-score-item .result-value {
    color: #b7950b;
    font-weight: 800;
    font-size: 1.1em;
}

.performance-rating {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Rating Guide Styles */
.rating-guide {
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 10px;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rating-guide summary {
    cursor: pointer;
    font-weight: 600;
    color: #2c5530;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.rating-guide summary:hover {
    background-color: rgba(44, 85, 48, 0.1);
}

.rating-criteria {
    margin-top: 10px;
    padding-top: 10px;
}

.rating-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 4px;
    background: rgba(248, 248, 248, 0.7);
}

.rating-badge {
    font-size: 1em;
    font-weight: bold;
    min-width: 140px;
    margin-right: 15px;
}

.rating-desc {
    font-size: 0.9em;
    color: #555;
    font-family: monospace;
}

.rating-note {
    margin-top: 12px;
    font-size: 0.85em;
    font-style: italic;
    color: #666;
    background: rgba(255, 255, 255, 0.8);
    padding: 8px;
    border-radius: 4px;
    border-left: 3px solid #2c5530;
}

/* History Modal Styles */
.history-stats {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.history-stats h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.history-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.overview-item {
    background: white;
    padding: 12px 8px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.overview-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    display: block;
}

.overview-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
    transition: transform 0.2s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-date {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 600;
}

.history-rating {
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
}

.history-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    font-size: 0.85rem;
}

.history-detail {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.history-detail-label {
    color: #6c757d;
    font-weight: 500;
}

.history-detail-value {
    font-weight: 600;
    color: #2c3e50;
}

.no-history {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.no-history .icon {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-history h3 {
    margin-bottom: 10px;
    color: #495057;
}

.no-history p {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Error analysis styles removed for simplicity */

/* Pause Overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: none;
    z-index: 3000;
    animation: fadeInOverlay 0.4s ease-out;
}

.pause-overlay.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-content {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 50px 40px;
    border-radius: 25px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    color: white;
    max-width: 400px;
    width: 90%;
    position: relative;
    overflow: hidden;
    animation: slideInPause 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pause-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
    transform: rotate(45deg);
}

.pause-icon {
    margin-bottom: 25px;
    position: relative;
    z-index: 1;
}

.pause-symbol {
    font-size: 4rem;
    display: block;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.pause-title {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 0 0 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: slideInUp 0.8s ease-out 0.2s both;
}

.pause-subtitle {
    font-size: 1.1rem;
    margin: 0 0 35px 0;
    opacity: 0.9;
    animation: slideInUp 0.8s ease-out 0.4s both;
}

.resume-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
    border: none;
    padding: 18px 40px;
    border-radius: 50px;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.4);
    animation: slideInUp 0.8s ease-out 0.6s both;
    z-index: 1;
}

.resume-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;
}

.resume-btn:hover::before {
    left: 100%;
}

.resume-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 35px rgba(40, 167, 69, 0.6);
    background: linear-gradient(45deg, #218838, #17a2b8);
}

.resume-btn:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.8);
}

.btn-text {
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.btn-icon {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.resume-btn:hover .btn-icon {
    transform: translateX(5px);
}

/* Animations */
@keyframes fadeInOverlay {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

@keyframes slideInPause {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Achievement Notification */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 20px;
    max-width: 350px;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.5s ease;
    z-index: 2000;
    border-left: 5px solid #28a745;
}

.achievement-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.achievement-content {
    display: flex;
    align-items: center;
}

.achievement-icon {
    font-size: 2.5rem;
    margin-right: 15px;
}

.achievement-text h3 {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.achievement-text p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9rem;
}

/* Achievements in Results Modal */
.achievements-unlocked {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #f1c40f;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(241, 196, 15, 0.2);
}

.achievements-unlocked h4 {
    color: #d68910;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 15px 0;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.unlocked-achievements {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.unlocked-achievement {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.unlocked-achievement:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.unlocked-achievement .achievement-icon {
    font-size: 2rem;
    margin-right: 12px;
    margin: 0;
    width: 40px;
    text-align: center;
}

.achievement-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.achievement-name {
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
    line-height: 1.2;
}

.achievement-desc {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.3;
}

/* Dark mode styles for achievements */
body.dark-mode .achievements-unlocked {
    background: linear-gradient(135deg, #3d3d00 0%, #4d4d00 100%);
    border-color: #f39c12;
}

body.dark-mode .achievements-unlocked h4 {
    color: #f1c40f;
}

body.dark-mode .unlocked-achievement {
    background: rgba(45, 45, 45, 0.9);
    border-left-color: #28a745;
}

body.dark-mode .achievement-name {
    color: #f0f0f0;
}

body.dark-mode .achievement-desc {
    color: #b0b0b0;
}

/* Dark mode achievement score styling */
body.dark-mode .achievement-score-item {
    background: linear-gradient(135deg, #4d4d00 0%, #666600 100%) !important;
    border-left-color: #f1c40f !important;
}

body.dark-mode .achievement-score-item .result-label {
    color: #f1c40f;
}

body.dark-mode .achievement-score-item .result-value {
    color: #f4d03f;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .achievements-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .test-controls {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .test-controls .btn {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .text-display {
        font-size: 1.2rem;
        padding: 25px;
        min-height: 150px;
        font-weight: 600;
    }
    
    /* TTS Button responsive for tablet */
    .tts-button {
        width: 40px;
        height: 40px;
        font-size: 16px;
        bottom: 10px;
        left: 10px;
    }
    
    .typing-input {
        font-size: 1.1rem;
        min-height: 130px;
        padding: 20px;
        font-weight: 600;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 98%;
        margin: 1% auto;
        max-height: 95vh;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
    }
    
    .btn-social {
        width: 100%;
        margin: 5px 0;
    }
    
    .achievement-notification {
        right: 10px;
        top: 10px;
        max-width: calc(100vw - 20px);
        transform: translateY(-100px);
    }
    
    .achievement-notification.show {
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .options-row {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .setting-group {
        justify-content: space-between;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-item {
        padding: 15px 10px;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .text-display {
        font-size: 1.1rem;
        padding: 20px;
        line-height: 1.40;
        min-height: 130px;
        font-weight: 600;
    }
    
    /* TTS Button responsive for small mobile */
    .tts-button {
        width: 36px;
        height: 36px;
        font-size: 14px;
        bottom: 8px;
        left: 8px;
    }
    
    .typing-input {
        font-size: 1rem;
        min-height: 120px;
        padding: 18px;
        font-weight: 600;
    }
    
    .results-score {
        font-size: 2rem;
    }
    
    .achievement {
        flex-direction: column;
        text-align: center;
    }
    
    .achievement-icon {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* High contrast mode support */
/* Dark mode text highlighting improvements - Preserves Arabic connections */
body.dark-mode .text-display .text-segment.correct {
    background-color: rgba(45, 90, 61, 0.7);
    color: #a5d6a7;
    box-shadow: 0 2px 4px rgba(165, 214, 167, 0.1);
}

body.dark-mode .text-display .text-segment.incorrect {
    background-color: rgba(92, 42, 42, 0.8);
    color: #ef9a9a;
    text-decoration: underline wavy #f44336;
    text-underline-offset: 3px;
    box-shadow: 0 2px 4px rgba(239, 154, 154, 0.1);
}

body.dark-mode .text-display .text-segment.current {
    background-color: rgba(25, 118, 210, 0.9);
    color: white;
    box-shadow: 0 0 8px rgba(25, 118, 210, 0.4);
}

body.dark-mode .text-display .text-segment.pending {
    color: #b0b0b0;
    opacity: 0.7;
}

/* Dark mode character-level highlighting */
body.dark-mode .text-display .text-char.correct {
    background: linear-gradient(to bottom, rgba(45, 90, 61, 0.4) 0%, rgba(45, 90, 61, 0.8) 100%);
    color: #a5d6a7;
    text-shadow: 0 0 2px rgba(165, 214, 167, 0.4);
}

body.dark-mode .text-display .text-char.incorrect {
    background: linear-gradient(to bottom, rgba(92, 42, 42, 0.5) 0%, rgba(92, 42, 42, 0.9) 100%);
    color: #ef9a9a;
    text-shadow: 0 0 3px rgba(244, 67, 54, 0.6);
    box-shadow: inset 0 -2px 0 0 rgba(244, 67, 54, 0.8);
}

body.dark-mode .text-display .text-char.current {
    background: linear-gradient(to bottom, rgba(25, 118, 210, 0.7) 0%, rgba(25, 118, 210, 1) 100%);
    color: white;
    text-shadow: 0 0 4px rgba(25, 118, 210, 0.9);
}

body.dark-mode .text-display .text-char.pending {
    color: #b0b0b0;
    opacity: 0.7;
}

/* Dark mode TTS button */
body.dark-mode .tts-button {
    background: linear-gradient(135deg, #8fa3ea 0%, #9bb5ea 100%);
    box-shadow: 0 4px 12px rgba(143, 163, 234, 0.3);
}

body.dark-mode .tts-button:hover {
    background: linear-gradient(135deg, #9bb5ea 0%, #8fa3ea 100%);
    box-shadow: 0 6px 20px rgba(143, 163, 234, 0.4);
}

body.dark-mode .tts-button.speaking {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
}

body.dark-mode .tts-button.error {
    background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
}

@media (prefers-contrast: high) {
    .text-display .text-segment.correct {
        background-color: #000;
        color: #fff;
    }
    
    .text-display .text-segment.incorrect {
        background-color: #fff;
        color: #000;
        outline: 2px solid #000;
    }
    
    .text-display .text-segment.current {
        background-color: #000;
        color: #fff;
        outline: 3px solid #fff;
    }
    
    /* High contrast character-level highlighting */
    .text-display .text-char.correct {
        background-color: #000;
        color: #fff;
        text-shadow: none;
    }
    
    .text-display .text-char.incorrect {
        background-color: #fff;
        color: #000;
        text-shadow: none;
        box-shadow: inset 0 -3px 0 0 #000;
    }
    
    .text-display .text-char.current {
        background-color: #000;
        color: #fff;
        outline: 2px solid #fff;
        text-shadow: none;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .achievement-notification {
        transition: none;
    }
}

/* Theme Toggle Button - Compact floating design */
.theme-toggle-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999; /* Higher z-index to avoid overlapping modals */
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1.5px solid #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: auto;
    white-space: nowrap;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #8fa3ea;
}

.theme-icon {
    font-size: 1rem;
    display: inline-block;
}

/* Dark mode styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #f0f0f0;
}

body.dark-mode .settings-panel,
body.dark-mode .test-area,
body.dark-mode .results-panel,
body.dark-mode .achievements-panel {
    background: #2d2d2d;
    color: #f5f5f5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Improve headings visibility in dark mode */
body.dark-mode .settings-panel h2,
body.dark-mode .results-panel h2,
body.dark-mode .achievements-panel h2 {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode .text-display {
    background: #3a3a3a;
    color: #ffffff;
    border-color: #555;
    font-weight: 600;
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
}

body.dark-mode .typing-input {
    background: #3a3a3a;
    color: #ffffff;
    border-color: #555;
    font-weight: 600;
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
}

/* Improve placeholder text in dark mode */
body.dark-mode .typing-input::placeholder {
    color: #b0b0b0;
    font-weight: 500;
}

body.dark-mode .modal-content {
    background-color: #2d2d2d;
    color: #f5f5f5;
}

body.dark-mode .stat-item,
body.dark-mode .result-item {
    background: #3a3a3a;
    border-color: #667eea;
    color: #ffffff;
}

/* Improve stats text visibility */
body.dark-mode .stat-label {
    color: #e8e8e8;
    font-weight: 600;
}

body.dark-mode .stat-value {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Improve achievement text visibility */
body.dark-mode .achievement-info h4 {
    color: #ffffff;
    font-weight: 700;
}

body.dark-mode .achievement-info p {
    color: #e8e8e8;
    font-weight: 500;
}

body.dark-mode .theme-toggle-btn {
    background: rgba(45, 45, 45, 0.95);
    color: #e0e0e0;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .theme-toggle-btn:hover {
    background: rgba(45, 45, 45, 1);
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: #8fa3ea;
}

/* Completely hide floating theme toggle on mobile - use sidebar instead */
@media screen and (max-width: 768px) {
    .theme-toggle-container {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        position: absolute !important;
        left: -9999px !important;
        top: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        pointer-events: none !important;
    }
}

@media screen and (max-width: 480px) {
    .theme-toggle-container {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* Mobile theme toggle in sidebar - Enhanced Design */
.mobile-theme-toggle-item {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 20px 0 15px 0;
    padding: 20px 15px 10px 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.mobile-theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 90%;
    max-width: 220px;
    min-height: 48px;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 30px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(15px);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mobile-theme-toggle-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.mobile-theme-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.mobile-theme-toggle-btn:hover:before {
    left: 100%;
}

.mobile-theme-toggle-btn:active {
    transform: translateY(0px) scale(0.98);
    transition: all 0.1s ease;
}

.mobile-theme-toggle-btn .theme-icon {
    font-size: 20px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mobile-theme-toggle-btn:hover .theme-icon {
    transform: scale(1.2) rotate(15deg);
}

.mobile-theme-toggle-btn .theme-text {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Ensure floating button is completely hidden on mobile */
@media (max-width: 768px) {
    .theme-toggle-container {
        display: none !important;
    }
}

/* Dark mode styles for mobile button */
body.dark-mode .mobile-theme-toggle-btn {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: rgba(102, 126, 234, 0.3);
    color: #e0e0e0;
}

body.dark-mode .mobile-theme-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.2) 100%);
    border-color: rgba(102, 126, 234, 0.4);
}

/* Mobile Menu Functionality */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background-color: #333;
    margin: 2px 0;
    transition: all 0.3s ease;
    border-radius: 1px;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.mobile-menu-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.mobile-menu-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-links {
    flex: 1;
    padding: 20px;
    list-style: none;
    margin: 0;
}

.mobile-menu-links li {
    margin-bottom: 15px;
}

.mobile-menu-links a {
    color: white;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.mobile-menu-links a:hover {
    padding-left: 10px;
    color: #f0f0f0;
}

.mobile-menu-social {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.mobile-menu-social a {
    color: white;
    font-size: 18px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.mobile-menu-social a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Show hamburger on mobile */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }
    
    .desktop-nav {
        display: none;
    }
    
    .desktop-social {
        display: none;
    }
    
    .mobile-header-link {
        display: block;
    }
}

/* Dark mode hamburger */
body.dark-mode .hamburger-line {
    background-color: #f0f0f0;
}

/* iPad Arabic Text Rendering Fixes - Enhanced */
@media only screen and (device-width: 768px) and (device-height: 1024px),
       only screen and (device-width: 1024px) and (device-height: 768px),
       only screen and (device-width: 820px) and (device-height: 1180px),
       only screen and (device-width: 1180px) and (device-height: 820px),
       only screen and (-webkit-min-device-pixel-ratio: 1) and (max-device-width: 1024px),
       only screen and (-webkit-min-device-pixel-ratio: 2) and (max-device-width: 1024px) {
    
    /* Critical: Force proper Arabic text shaping and connections */
    .arabic-text, .text-display, .typing-input, .arabic-input {
        /* Essential Arabic font features */
        font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1, "ccmp" 1, "locl" 1, "mset" 1 !important;
        -webkit-font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1, "ccmp" 1, "locl" 1, "mset" 1 !important;
        -moz-font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1, "ccmp" 1, "locl" 1, "mset" 1 !important;
        font-variant-ligatures: common-ligatures contextual !important;
        
        /* Optimize text rendering for Arabic */
        text-rendering: optimizeLegibility !important;
        -webkit-text-size-adjust: 100%;
        font-synthesis: none;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        
        /* Force proper Arabic text flow and direction */
        unicode-bidi: embed !important;
        direction: rtl !important;
        text-align: right !important;
        
        /* Critical: Prevent any text breaking that separates letters */
        word-break: keep-all !important;
        overflow-wrap: normal !important;
        white-space: pre-wrap !important;
        hyphens: none !important;
        
        /* Ensure proper Arabic font stack with iPad-optimized fonts */
        font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arabic Typesetting', 'Geeza Pro', 'Baghdad', 'Al Bayan', 'PingFang TC', 'Apple Color Emoji', 'Times New Roman', serif !important;
    }
    
    /* CRITICAL: Character-level highlighting that maintains Arabic connections */
    .text-display .text-char {
        /* Force inline display to preserve text flow */
        display: inline !important;
        float: none !important;
        position: static !important;
        
        /* Inherit all font shaping from parent - essential for Arabic */
        font-feature-settings: inherit !important;
        -webkit-font-feature-settings: inherit !important;
        font-variant-ligatures: inherit !important;
        
        /* Prevent any CSS properties that break Arabic shaping */
        transform: none !important;
        letter-spacing: 0 !important;
        word-spacing: 0 !important;
        text-indent: 0 !important;
        
        /* Remove any spacing/padding that could separate characters */
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        outline: none !important;
        
        /* Force proper text rendering */
        text-rendering: inherit !important;
        -webkit-text-size-adjust: inherit !important;
        white-space: inherit !important;
        
        /* Remove any visual effects that might interfere */
        box-shadow: none !important;
        text-shadow: none !important;
        background: transparent !important;
    }
    
    /* Alternative highlighting using underline/overline for iPad */
    .text-display .text-char.correct {
        color: #155724 !important;
        text-decoration: underline !important;
        text-decoration-color: #d4edda !important;
        text-decoration-thickness: 3px !important;
        text-underline-offset: 3px !important;
    }
    
    .text-display .text-char.incorrect {
        color: #721c24 !important;
        text-decoration: underline !important;
        text-decoration-color: #f8d7da !important;
        text-decoration-thickness: 3px !important;
        text-underline-offset: 3px !important;
    }
    
    .text-display .text-char.current {
        color: #0066cc !important;
        text-decoration: underline !important;
        text-decoration-color: #007bff !important;
        text-decoration-thickness: 4px !important;
        text-underline-offset: 2px !important;
        animation: currentBlink 1s infinite;
    }
    
    .text-display .text-char.pending {
        color: #6c757d !important;
        opacity: 0.8;
    }
    
    /* Ensure text content containers preserve Arabic rendering */
    .text-content {
        display: inline !important;
        font-feature-settings: inherit !important;
        -webkit-font-feature-settings: inherit !important;
        /* Force continuous text flow */
        white-space: pre-wrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }
    
    /* Fix any potential span wrapping issues */
    .text-display span:not(.text-char), .typing-input span:not(.text-char) {
        font-feature-settings: inherit !important;
        -webkit-font-feature-settings: inherit !important;
        display: inline !important;
    }
    
    /* Force proper Arabic text rendering in all nested elements */
    .text-display *, .typing-input * {
        font-feature-settings: inherit !important;
        -webkit-font-feature-settings: inherit !important;
        direction: inherit !important;
        unicode-bidi: inherit !important;
    }
    
    /* CRITICAL iPad Safari Fix: Force text continuity */
    .text-display .text-content {
        /* Override any CSS that might force character separation */
        -webkit-user-select: text !important;
        -webkit-touch-callout: default !important;
        -webkit-tap-highlight-color: transparent !important;
        
        /* Force browser to treat as continuous Arabic text */
        speak: spell-out;
        -webkit-writing-mode: horizontal-tb !important;
        writing-mode: horizontal-tb !important;
        
        /* Ensure no interference with text shaping */
        -webkit-appearance: none !important;
        appearance: none !important;
    }
    
    /* Additional Safari-specific fixes */
    @supports (-webkit-touch-callout: none) {
        .text-display .text-char {
            /* iOS Safari specific: prevent any layout that breaks Arabic */
            contain: none !important;
            isolation: auto !important;
        }
    }
    
    /* iPad Arabic fix class applied by JavaScript */
    .ipad-arabic-fix {
        font-kerning: auto !important;
        font-optical-sizing: auto !important;
        text-rendering: optimizeLegibility !important;
        
        /* Force Safari to use proper Arabic text shaping */
        -webkit-locale: "ar" !important;
        -webkit-text-stroke: 0 !important;
        -webkit-text-fill-color: inherit !important;
    }
    
    .ipad-arabic-fix .text-char {
        /* Ensure character spans don't break Arabic connections */
        display: inline !important;
        font-synthesis: none !important;
        font-kerning: inherit !important;
    }
    
    /* Style for ZWJ connectors - make them invisible but functional */
    .zwj-connector {
        display: inline !important;
        font-size: 0 !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        /* Ensure ZWJ characters maintain their connecting function */
        unicode-bidi: embed !important;
        direction: inherit !important;
        font-feature-settings: inherit !important;
        -webkit-font-feature-settings: inherit !important;
    }
}

/* General Arabic text improvements for all devices */
.arabic-text, .text-display, .typing-input {
    /* Enable Arabic text shaping features */
    font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1;
    -webkit-font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1;
    -moz-font-feature-settings: "liga" 1, "calt" 1, "curs" 1, "kern" 1;
    font-variant-ligatures: common-ligatures contextual;
    text-rendering: optimizeLegibility;
}

/* Ensure character highlighting doesn't break Arabic connections */
.text-char {
    /* Preserve Arabic text shaping when highlighting individual characters */
    font-feature-settings: inherit !important;
    -webkit-font-feature-settings: inherit !important;
    display: inline !important;
}

/* Fix button colors in dark mode */
body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 1px solid #667eea;
}

body.dark-mode .btn-secondary {
    background: #495057;
    color: #e0e0e0;
    border: 1px solid #495057;
}

body.dark-mode .btn-secondary:hover:not(:disabled) {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
}

body.dark-mode .btn-warning {
    background: #ffc107;
    color: #212529;
    border: 1px solid #ffc107;
}

body.dark-mode .btn-warning:hover:not(:disabled) {
    background: #e0a800;
    border-color: #e0a800;
    color: #212529;
}

body.dark-mode .btn-social.facebook {
    background: #1877f2;
    color: white;
    border: 1px solid #1877f2;
}

body.dark-mode .btn-social.x-twitter {
    background: #1a1a1a;
    color: white;
    border: 1px solid #444;
}

body.dark-mode .btn-social.x-twitter:hover {
    background: #333;
    border-color: #666;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

body.dark-mode .btn-social.whatsapp {
    background: #25d366;
    color: white;
    border: 1px solid #25d366;
}

body.dark-mode .btn-download {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: 1px solid #28a745;
}

body.dark-mode .btn-download:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838 0%, #1ea47c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

body.dark-mode .btn:disabled {
    background: #6c757d;
    color: #adb5bd;
    border-color: #6c757d;
    opacity: 0.6;
}

/* Fix modal header and footer in dark mode */
body.dark-mode .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

body.dark-mode .modal-footer {
    background: #3a3a3a;
    border-color: #555;
}

/* Ensure all form elements are readable in dark mode */
body.dark-mode input, 
body.dark-mode textarea {
    background: #3a3a3a;
    color: #f5f5f5;
    border-color: #555;
}

body.dark-mode label {
    color: #f0f0f0;
}

body.dark-mode .achievement.unlocked {
    background: linear-gradient(135deg, #2d5a3d 0%, #3d6b4d 100%);
    border-color: #28a745;
}

body.dark-mode .achievement.locked {
    background: #3a3a3a;
    border-color: #555;
}

body.dark-mode select {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .progress-bar {
    background-color: #404040;
    border-color: #555;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode .progress-fill {
    background: linear-gradient(90deg, #28a745 0%, #20c997 50%, #17a2b8 100%);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
}

body.dark-mode .progress-fill.urgent {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%) !important;
    box-shadow: 0 3px 12px rgba(220, 53, 69, 0.6) !important;
}

body.dark-mode .progress-fill.warning {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%) !important;
    box-shadow: 0 2px 10px rgba(253, 126, 20, 0.5) !important;
}

body.dark-mode .progress-fill.low-time {
    background: linear-gradient(90deg, #f1c40f 0%, #f39c12 100%) !important;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.5) !important;
}

body.dark-mode .progress-fill.paused {
    background: linear-gradient(90deg, #495057 0%, #343a40 100%) !important;
    box-shadow: 0 2px 8px rgba(73, 80, 87, 0.4) !important;
    animation: none !important;
}

/* Animation classes for future use */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Description Sections */
.descrip {
    background: white;
    padding: 30px;
    margin: 30px 0;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    line-height: 1.8;
    text-align: center;
}

.descrip p {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.1rem;
}

.descrip b {
    color: #667eea;
    font-weight: 600;
}

.desc2 {
    background: white;
    padding: 30px;
    margin: 30px 0;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.desc2 h2 {
    color: #2c3e50;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
    font-size: 1.5rem;
    text-align: center;
}

/* Tool Buttons Grid */
.tools-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 15px;
    margin-bottom: 40px;
}

.tool-button {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    text-decoration: none;
    color: #2c3e50;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.tool-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.6s;
}

.tool-button:hover::before {
    left: 100%;
}

.tool-button:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tool-icon {
    font-size: 1.8rem;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.tool-button:hover .tool-icon {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(10deg) scale(1.1);
}

.tool-text {
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* Social Links Footer */
.social-links-footer {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
}

.social-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 50%;
    color: #2c3e50;
    font-size: 1.8rem;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    border: 3px solid transparent;
}

.social-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    transition: transform 0.3s ease;
}

.social-button:hover::before {
    transform: scale(1);
}

.social-button:hover {
    transform: translateY(-8px) scale(1.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.social-button.instagram:hover {
    background: linear-gradient(45deg, #f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%);
    color: white;
    border-color: #e1306c;
}

.social-button.facebook:hover {
    background: linear-gradient(135deg, #4267B2 0%, #365899 100%);
    color: white;
    border-color: #4267B2;
}

.social-button.youtube:hover {
    background: linear-gradient(135deg, #FF0000 0%, #CC0000 100%);
    color: white;
    border-color: #FF0000;
}

.social-button.tiktok:hover {
    background: linear-gradient(135deg, #000000 0%, #333333 100%);
    color: white;
    border-color: #000000;
}

/* Dark mode styles for description sections */
body.dark-mode .descrip,
body.dark-mode .desc2 {
    background: #2c2c2c;
    color: #e0e0e0;
}

body.dark-mode .descrip p {
    color: #e0e0e0;
}

body.dark-mode .descrip b {
    color: #8fa3ea;
}

body.dark-mode .desc2 h2 {
    color: #f0f0f0;
    border-color: #8fa3ea;
}

/* Dark mode for tool buttons */
body.dark-mode .tool-button {
    background: linear-gradient(135deg, #3a3a3a 0%, #2c2c2c 100%);
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .tool-button:hover {
    background: linear-gradient(135deg, #8fa3ea 0%, #a8b5e8 100%);
    color: white;
}

body.dark-mode .tool-icon {
    background: rgba(143, 163, 234, 0.2);
}

/* Dark mode for social buttons */
body.dark-mode .social-button {
    background: linear-gradient(135deg, #3a3a3a 0%, #2c2c2c 100%);
    color: #e0e0e0;
    border-color: #555;
}

/* Dark mode for pause overlay */
body.dark-mode .pause-overlay {
    background: rgba(0, 0, 0, 0.9);
}

body.dark-mode .pause-content {
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

body.dark-mode .pause-content::before {
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
}

/* Dark mode for new single onboarding arrow */
body.dark-mode .arrow-line {
    background: linear-gradient(90deg, #8fa3ea, #a8b5e8);
}

body.dark-mode .right-pointing .arrow-tip {
    border-left-color: #a8b5e8;
}

body.dark-mode .arrow-text-above {
    background: linear-gradient(135deg, #8fa3ea 0%, #a8b5e8 100%);
    box-shadow: 0 6px 20px rgba(143, 163, 234, 0.4);
}

/* Dark mode for integrated controls */
body.dark-mode .integrated-controls {
    background: linear-gradient(135deg, #3a3a3a 0%, #2c2c2c 100%);
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .integrated-controls::before {
    background: linear-gradient(90deg, transparent, rgba(143, 163, 234, 0.1), transparent);
}

body.dark-mode .control-item label {
    color: #f0f0f0;
}

body.dark-mode .control-item label i {
    color: #8fa3ea;
}

body.dark-mode .modern-select {
    background: #3a3a3a;
    color: #e0e0e0;
    border-color: #555;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23a8d5ff" d="m0 1 2 2 2-2z"/></svg>') !important; /* Light blue arrow - force single arrow */
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 10px !important;
}

body.dark-mode .modern-select:hover {
    border-color: #8fa3ea;
    background-color: #444;
    box-shadow: 0 4px 12px rgba(143, 163, 234, 0.2);
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23ffffff" d="m0 1 2 2 2-2z"/></svg>') !important; /* White arrow on hover - force single arrow */
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 10px !important;
}

body.dark-mode .modern-select:focus {
    border-color: #8fa3ea;
    background-color: #444;
    box-shadow: 0 0 0 3px rgba(143, 163, 234, 0.2);
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23ffffff" d="m0 1 2 2 2-2z"/></svg>') !important; /* White arrow on focus - force single arrow */
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 10px !important;
}

/* Refresh Button Styles */
.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 100px;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.refresh-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.refresh-btn:hover::before {
    left: 100%;
}

.refresh-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
    background: linear-gradient(135deg, #218838 0%, #17a2b8 100%);
}

.refresh-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.5);
}

.refresh-btn i {
    font-size: 1rem;
    animation: none;
    transition: transform 0.3s ease;
}

.refresh-btn:hover i {
    animation: rotateRefresh 0.6s ease-in-out;
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: #6c757d;
    box-shadow: none;
}

.refresh-btn:disabled:hover {
    transform: none;
    background: #6c757d;
    box-shadow: none;
}

.refresh-btn:disabled i {
    animation: none;
}

@keyframes rotateRefresh {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dark mode styles for refresh button */
body.dark-mode .refresh-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.4);
}

body.dark-mode .refresh-btn:hover {
    background: linear-gradient(135deg, #34ce57 0%, #17a2b8 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.5);
}

body.dark-mode .refresh-btn:disabled {
    background: #495057;
    color: #adb5bd;
}

/* Dark mode for rating and performance elements */
body.dark-mode .performance-rating {
    background: linear-gradient(135deg, #3a3a3a 0%, #2c2c2c 100%);
    color: #e0e0e0;
}

body.dark-mode .rating-guide {
    background: rgba(45, 45, 45, 0.9);
    color: #e0e0e0;
}

body.dark-mode .rating-guide summary {
    color: #8fa3ea;
}

body.dark-mode .rating-guide summary:hover {
    background-color: rgba(143, 163, 234, 0.1);
}

body.dark-mode .rating-item {
    background: rgba(58, 58, 58, 0.7);
    color: #e0e0e0;
}

body.dark-mode .rating-desc {
    color: #b0b0b0;
}

body.dark-mode .rating-note {
    color: #e0e0e0;
    background: rgba(58, 58, 58, 0.8);
    border-left-color: #8fa3ea;
}

/* Dark mode for history elements */
body.dark-mode .history-stats {
    background: linear-gradient(135deg, #3a3a3a 0%, #2c2c2c 100%);
    color: #e0e0e0;
}

body.dark-mode .history-stats h3 {
    color: #f0f0f0;
}

body.dark-mode .overview-item {
    background: #3a3a3a;
    color: #e0e0e0;
}

body.dark-mode .overview-value {
    color: #8fa3ea;
}

body.dark-mode .overview-label {
    color: #b0b0b0;
}

body.dark-mode .history-item {
    background: #3a3a3a;
    border-left-color: #8fa3ea;
    color: #e0e0e0;
}

body.dark-mode .history-date {
    color: #b0b0b0;
}

body.dark-mode .history-rating {
    background: #2c2c2c;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .history-detail-label {
    color: #b0b0b0;
}

body.dark-mode .history-detail-value {
    color: #f0f0f0;
}

body.dark-mode .no-history {
    color: #b0b0b0;
}

body.dark-mode .no-history h3 {
    color: #e0e0e0;
}

body.dark-mode .no-history p {
    color: #b0b0b0;
}

/* Dark mode for results modal elements */
body.dark-mode .results-score {
    color: #8fa3ea;
}

body.dark-mode .result-label {
    color: #f0f0f0;
}

body.dark-mode .result-value {
    color: #8fa3ea;
}

/* Dark mode for new title */
body.dark-mode .main-title h1 {
    color: #f0f0f0;
}

/* Dark mode mobile header link */
body.dark-mode .mobile-learn-arabic {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #f8f9fa;
}

body.dark-mode .mobile-learn-arabic:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* Large tablet and desktop - ensure horizontal layout */
@media (min-width: 769px) {
    .tools-grid {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    .tool-button {
        flex: 0 0 auto;
        min-width: 200px;
    }
    
    /* Ensure arrow visibility on larger screens */
    .onboarding-arrows {
        left: -160px; /* Closer positioning for better visibility */
    }
    
    .arrow-line {
        width: 140px; /* Appropriate length for desktop */
    }
}

/* Extra large screens - ensure optimal arrow positioning */
@media (min-width: 1400px) {
    .onboarding-arrows {
        left: -190px; /* Further positioning for very large screens */
    }
    
    .arrow-line {
        width: 170px; /* Longer line for large screens */
    }
}

/* Mobile Header Link - Hidden on Desktop */
.mobile-header-link {
    display: none;
}

/* Mobile responsive navigation */
@media (max-width: 768px) {
    body {
        padding-top: 70px; /* Space for mobile header */
    }
    
    .header {
        padding: 10px 20px;
        border-radius: 0;
    }
    
    .header-content {
        justify-content: space-between;
        align-items: center;
    }
    
    /* Show mobile header link */
    .mobile-header-link {
        display: flex;
        flex: 1;
        justify-content: center;
    }
    
    .mobile-learn-arabic {
        color: white;
        text-decoration: none;
        font-size: 1.1rem;
        font-weight: 600;
        padding: 8px 16px;
        border-radius: 20px;
        background-color: rgba(255, 255, 255, 0.1);
        transition: all 0.3s ease;
        text-align: center;
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .mobile-learn-arabic:hover {
        background-color: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    }
    
    /* Show hamburger button on mobile */
    .hamburger-btn {
        display: flex;
    }
    
    /* Hide desktop navigation on mobile */
    .desktop-nav,
    .desktop-social {
        display: none;
    }
    
    .main-title {
        margin: 15px 0 20px 0;
    }
    
    .main-title h1 {
        font-size: 1.6rem;
    }
    
    .integrated-controls {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px 16px;
        justify-content: center;
    }
    
    .control-item {
        flex: 0 1 auto;
        min-width: 140px;
    }
    
    .control-item {
        flex: 0 1 auto;
        min-width: 140px;
    }
    
    .control-item label {
        font-size: 0.8rem;
    }
    
    .modern-select {
        min-width: 120px;
        font-size: 0.8rem;
        padding: 6px 12px;
        padding-right: 28px;
    }
    
    .descrip,
    .desc2 {
        margin: 20px 15px;
        padding: 20px;
    }
    
    .descrip p {
        font-size: 1rem;
    }
    
    .desc2 h2 {
        font-size: 1.3rem;
    }
    
    .tools-grid {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        align-items: stretch;
        justify-content: center;
    }
    
    .tool-button {
        padding: 15px;
    }
    
    .tool-icon {
        width: 50px;
        height: 50px;
        font-size: 2rem;
        margin-right: 12px;
    }
    
    .tool-text {
        font-size: 1rem;
    }
    
    .social-links-footer {
        gap: 20px;
    }
    
    .social-button {
        width: 55px;
        height: 55px;
        font-size: 1.6rem;
    }
    
    /* Pause overlay mobile */
    .pause-content {
        padding: 40px 30px;
        max-width: 350px;
    }
    
    .pause-title {
        font-size: 1.8rem;
    }
    
    .pause-subtitle {
        font-size: 1rem;
    }
    
    .resume-btn {
        padding: 15px 35px;
        font-size: 1.1rem;
    }
    
    .pause-symbol {
        font-size: 3.5rem;
    }
    
    /* Onboarding guide mobile */
    .onboarding-guide {
        right: -160px;
        transform: translateY(-50%) scale(0.9);
    }
    
    .arrow-body {
        width: 50px;
    }
    
    .guide-text {
        font-size: 0.8rem;
        padding: 10px 14px;
    }
    
    .guide-message {
        font-size: 0.85rem;
    }
    
    .guide-message-arabic {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 70px; /* Consistent mobile header space */
    }
    
    .header {
        width: 98%;
    }
    
    .main-title h1 {
        font-size: 1.4rem;
        line-height: 1.2;
    }
    
    /* Single onboarding arrow mobile adjustments */
    .onboarding-arrows {
        left: -160px; /* Much closer to container on mobile */
    }
    
    .arrow-line {
        width: 80px;
        height: 3px;
    }
    
    .arrow-text-above {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
    
    .guide-message-english {
        font-size: 0.85rem;
    }
    
    .navbar ul {
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .navbar ul li a {
        font-size: 0.83rem;
        padding: 3px 6px;
        font-weight: bold;
    }
    
    .header-social-links {
        gap: 6px;
    }
    
    .header-social-links a {
        width: 26px;
        height: 26px;
        font-size: 1.03rem;
    }
    
    .integrated-controls {
        padding: 8px 12px;
        gap: 8px;
        justify-content: center;
    }
    
    .control-item {
        flex: 0 1 auto;
        min-width: 100px;
    }
    
    .control-item label {
        font-size: 0.75rem;
    }
    
    .control-item label span {
        display: none; /* Hide text labels on very small screens */
    }
    
    .modern-select {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 90px;
        padding-right: 24px;
    }
    
    .descrip p {
        font-size: 0.95rem;
    }
    
    .desc2 h2 {
        font-size: 1.2rem;
    }
    
    .tools-grid {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .tool-button {
        padding: 12px;
        width: 100%;
        max-width: 300px;
    }
    
    .tool-icon {
        width: 45px;
        height: 45px;
        font-size: 1.8rem;
        margin-right: 10px;
    }
    
    .tool-text {
        font-size: 0.9rem;
    }
    
    .social-links-footer {
        gap: 15px;
    }
    
    .social-button {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
    }
    
    /* Pause overlay smaller mobile */
    .pause-content {
        padding: 30px 20px;
        max-width: 300px;
    }
    
    .pause-title {
        font-size: 1.6rem;
    }
    
    .pause-subtitle {
        font-size: 0.9rem;
    }
    
    .resume-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
    
    .pause-symbol {
        font-size: 3rem;
    }
    
    /* Onboarding guide smaller mobile */
    .onboarding-guide {
        right: -140px;
        transform: translateY(-50%) scale(0.8);
    }
    
    .arrow-body {
        width: 40px;
        height: 2px;
    }
    
    .arrow-head {
        right: -6px;
        border-left-width: 10px;
        border-top-width: 6px;
        border-bottom-width: 6px;
    }
    
    .guide-text {
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    
    .guide-message {
        font-size: 0.8rem;
    }
    
    .guide-message-arabic {
        font-size: 0.7rem;
    }
}

/* Bilingual Content Table Styles */
.bilingual-content {
    width: 100%;
    margin: 20px 0;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: all 0.3s ease;
}

.content-table:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.content-table td {
    padding: 30px;
    vertical-align: top;
    width: 50%;
    border: none;
    position: relative;
    transition: all 0.4s ease;
}

.english-content {
    text-align: left;
    direction: ltr;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-right: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.english-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

.english-content:hover::before {
    left: 100%;
}

.arabic-content {
    text-align: right;
    direction: rtl;
    font-family: 'Noto Sans Arabic', 'Traditional Arabic', 'Arial Unicode MS', sans-serif;
    background: linear-gradient(135deg, #6a4c93 0%, #8b5a5b 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.arabic-content::before {
    content: '';
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: right 0.6s ease;
}

.arabic-content:hover::before {
    right: 100%;
}

.content-table p {
    margin: 18px 0;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.95);
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.content-table p:first-child {
    margin-top: 0;
}

.content-table p:last-child {
    margin-bottom: 0;
}

.content-table strong {
    color: #ffffff;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    backdrop-filter: blur(5px);
}

/* Dark mode styles for bilingual content */
body.dark-mode .content-table {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

body.dark-mode .content-table:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

body.dark-mode .english-content {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border-right: 2px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .arabic-content {
    background: linear-gradient(135deg, #553c9a 0%, #ee5a24 100%);
}

body.dark-mode .content-table p {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

body.dark-mode .content-table strong {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Responsive styles for bilingual table */
@media (max-width: 768px) {
    .bilingual-content {
        animation-delay: 0.2s;
    }
    
    .content-table {
        display: block;
        border-radius: 12px;
    }
    
    .content-table tr {
        display: block;
    }
    
    .content-table td {
        display: block;
        width: 100%;
        padding: 25px;
        border-right: none;
        border-bottom: 3px solid rgba(255, 255, 255, 0.3);
        animation: slideInLeft 0.6s ease-out forwards;
        opacity: 0;
    }
    
    .english-content {
        animation-delay: 0.1s;
        border-radius: 12px 12px 0 0;
    }
    
    .arabic-content {
        border-bottom: none;
        animation-delay: 0.3s;
        border-radius: 0 0 12px 12px;
    }
    
    .arabic-content::before {
        right: -100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    }
    
    body.dark-mode .english-content {
        border-right: none;
        border-bottom: 3px solid rgba(255, 255, 255, 0.2);
    }
    
    body.dark-mode .arabic-content {
        border-bottom: none;
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Add pulse animation on hover for mobile */
@media (max-width: 768px) {
    .content-table td:active {
        animation: pulse 0.3s ease-in-out;
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
