* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

main {
    padding: 40px;
}

/* Blocks Grid */
.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

/* Chapters Grid */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

/* Chapters Header */
.chapters-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 20px 0;
    border-bottom: 2px solid #e0e0e0;
}

.chapters-header h2 {
    color: #333;
    font-size: 2em;
    font-weight: 600;
    margin: 0;
}

/* Block Cards */
.block-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    padding: 30px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.block-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border-color: var(--block-color, #4facfe);
}

.block-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--block-color, #4facfe);
}

.block-icon {
    font-size: 4em;
    margin-bottom: 20px;
    display: block;
}

.block-card h3 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 15px;
    font-weight: 700;
}

.block-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 1.1em;
}

.block-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.block-stat {
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    color: #555;
    border: 1px solid #e0e0e0;
    font-weight: 600;
}

.enter-block-btn {
    width: 100%;
    padding: 15px 25px;
    background: var(--block-color, #4facfe);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.enter-block-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    filter: brightness(1.1);
}

/* Chapter Cards */
.chapter-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    border-color: #4facfe;
}

.chapter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4facfe, #00f2fe);
}

.chapter-card h3 {
    color: #333;
    font-size: 1.5em;
    margin-bottom: 10px;
    font-weight: 600;
}

.chapter-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    color: #555;
    border: 1px solid #e0e0e0;
}

.meta-item .icon {
    font-size: 1.1em;
}

.difficulty-easy {
    color: #4caf50;
    background: #e8f5e8;
    border-color: #4caf50;
}

.difficulty-medium {
    color: #ff9800;
    background: #fff3e0;
    border-color: #ff9800;
}

.difficulty-hard {
    color: #f44336;
    background: #ffebee;
    border-color: #f44336;
}

.start-btn {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .blocks-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chapters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .chapters-header h2 {
        font-size: 1.5em;
    }
    
    .block-card {
        padding: 20px;
    }
    
    .block-icon {
        font-size: 3em;
    }
    
    .block-card h3 {
        font-size: 1.5em;
    }
    
    .chapter-card {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2.5em;
    }
    
    main {
        padding: 20px;
    }
}

.loading {
    text-align: center;
    padding: 60px;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4facfe;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    text-align: center;
    padding: 60px;
    color: #f44336;
}

.error h3 {
    margin-bottom: 10px;
}

.back-btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1em;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* MathJax styling for index page */
.MathJax {
    font-size: 1em !important;
}

.test-card .MathJax {
    font-size: 0.9em !important;
}

/* Ensure math formulas are properly styled */
mjx-container {
    display: inline-block;
    margin: 0 0.1em;
}

@media (max-width: 768px) {
    .tests-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    header h1 {
        font-size: 2.5em;
    }
    
    main {
        padding: 20px;
    }
    
    .test-card {
        padding: 20px;
    }
}
