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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.8) 0%, rgba(118, 75, 162, 0.8) 100%), url('manjusri.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.stats {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Loading Screen */
.loading {
    text-align: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Welcome Screen */
.welcome {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.welcome h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #667eea;
}

.welcome p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #666;
}

.source-text {
    font-size: 1rem;
    margin-bottom: 15px;
    color: #555;
    font-style: italic;
}

.source-list {
    list-style: none;
    margin-bottom: 30px;
    padding: 0;
}

.source-list li {
    margin-bottom: 8px;
}

.source-list a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.source-list a:hover {
    color: #5a6fd8;
    text-decoration: underline;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.btn-easy {
    background: #28a745;
    color: white;
}

.btn-easy:hover {
    background: #218838;
    transform: translateY(-2px);
}

.btn-medium {
    background: #ffc107;
    color: #212529;
}

.btn-medium:hover {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-hard {
    background: #dc3545;
    color: white;
}

.btn-hard:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Study Screen */
.study {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.card-container {
    margin-bottom: 30px;
}

.card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
}

.card h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    line-height: 1.6;
    color: #333;
}

.card-front, .card-back {
    width: 100%;
}

.rating-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    width: 0%;
}

.session-info {
    text-align: center;
    font-size: 1.1rem;
    color: #666;
}

/* Stats Screen */
.stats-screen {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.stats-screen h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
    font-size: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #e9ecef;
}

.stat-card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.stat-card p {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

.difficulty-breakdown {
    margin-bottom: 30px;
}

.difficulty-breakdown h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #667eea;
}

.difficulty-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.difficulty-bar {
    display: flex;
    align-items: center;
    gap: 15px;
}

.difficulty-bar span:first-child {
    width: 80px;
    font-weight: 600;
}

.bar {
    flex: 1;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
    width: 0%;
}

.easy-fill {
    background: #28a745;
}

.medium-fill {
    background: #ffc107;
}

.hard-fill {
    background: #dc3545;
}

.difficulty-bar span:last-child {
    width: 50px;
    text-align: right;
    font-weight: 600;
}

/* All Cards Screen */
.all-cards {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.all-cards-header {
    padding: 20px 30px;
    border-bottom: 2px solid #e9ecef;
    text-align: center;
}

.all-cards-header h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.all-cards-header p {
    color: #666;
    margin-bottom: 20px;
}

.cards-filters {
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.filter-select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: #333;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
}

.filter-info {
    margin-left: auto;
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.cards-grid-container {
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    grid-auto-rows: min-content;
    gap: 20px;
    height: 100%;
    overflow-y: auto;
    padding-right: 10px;
    align-items: start;
}

.card-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 150px;
    height: fit-content;
    display: flex;
    flex-direction: column;
    position: relative;
}

.card-item:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.card-item.flipped .card-front {
    display: none;
}

.card-item.flipped .card-back {
    display: block;
}

.card-front, .card-back {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-back {
    display: none;
}

.card-question {
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    font-size: 1rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding-right: 60px;
}

.card-answer {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding-right: 60px;
}

.card-number {
    font-size: 0.8rem;
    color: #999;
    margin-top: 10px;
    text-align: right;
}

.card-rating {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.card-rating.easy {
    background: #28a745;
}

.card-rating.medium {
    background: #ffc107;
    color: #212529;
}

.card-rating.hard {
    background: #dc3545;
}

/* Session Complete Screen */
.session-complete {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.session-complete h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #28a745;
}

.session-complete p {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #666;
}

.session-stats {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.session-stats p {
    margin: 10px 0;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .welcome, .study, .stats-screen, .session-complete {
        padding: 20px;
    }
    
    .card {
        padding: 20px;
        min-height: 250px;
    }
    
    .card h3 {
        font-size: 1.3rem;
    }
    
    .rating-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .difficulty-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    
    .difficulty-bar span:first-child {
        width: auto;
        text-align: center;
    }
    
    .difficulty-bar span:last-child {
        width: auto;
        text-align: center;
    }
    
    .cards-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .filter-group {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .filter-info {
        margin-left: 0;
        text-align: center;
    }
}
