* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --light: #f9fafb;
    --dark: #111827;
    --gray: #6b7280;
    --border: #e5e7eb;
}

body {
    background-color: var(--light);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-content {
    text-align: center;
    color: white;
    margin-bottom: 50px;
}

.loading-title {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.loading-subtitle {
    font-size: 1.5rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Wave Progress Bar */
.wave-progress {
    width: 300px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-top: 30px;
}

.wave-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffffff, #e0e7ff);
    border-radius: 10px;
    transition: width 3s ease-in-out;
}

.wave-progress.complete .wave-progress-fill {
    width: 100%;
}

/* Continue Button */
.continue-btn {
    display: none;
    margin-top: 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.continue-btn i {
    font-size: 1.2rem;
}

/* Header */
.header {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo-text span {
    color: var(--dark);
    font-weight: 300;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.home-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), #3730a3);
    transform: translateY(-2px);
}

/* Home Page */
.home-page {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.home-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 50px;
    color: var(--dark);
}

.take-quiz-btn {
    display: block;
    margin: 0 auto;
    background: var(--primary);
    color: white;
    border: none;
    padding: 18px 40px;
    font-size: 1.3rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
}

.take-quiz-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
}

/* Subject Selection Page */
.subject-selection {
    padding: 30px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.page-title {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--dark);
    text-align: center;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.subject-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.subject-item {
    background: white;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.subject-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.subject-item i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.subject-name {
    font-weight: 600;
    color: var(--dark);
}

/* Quiz Type Page */
.quiz-type-page {
    padding: 30px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.quiz-type-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.back-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--primary-dark);
    transform: translateX(-3px);
}

.quiz-type-container {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.type-selector {
    margin-bottom: 30px;
    max-width: 300px;
}

/* Quiz Grid */
.quiz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.quiz-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 2px solid var(--border);
    position: relative;
    cursor: pointer;
}

.quiz-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.quiz-card.active {
    border-color: var(--primary);
}

.quiz-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.quiz-subject {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.quiz-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.status-available {
    background: #d1fae5;
    color: #065f46;
}

.quiz-details {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.quiz-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.quiz-questions {
    font-weight: 500;
}

.quiz-action {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-action:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Topic Grid */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.topic-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.topic-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.topic-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark);
}

.topic-count {
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 8px;
}

/* No Topics Message */
.no-topics-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.no-topics-message i {
    font-size: 3rem;
    color: var(--warning);
    margin-bottom: 15px;
}

.no-topics-message p {
    margin-bottom: 10px;
}

.no-topics-message p:first-of-type {
    font-weight: 600;
    color: var(--dark);
}

/* Quiz Screen */
.quiz-screen {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.quiz-subject-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--primary);
}

.quiz-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    background: #f3f4f6;
    padding: 8px 16px;
    border-radius: 8px;
    min-width: 80px;
    text-align: center;
}

.timer-warning {
    color: var(--warning);
}

.timer-danger {
    color: var(--danger);
}

/* Question Grid */
.question-grid-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.question-grid-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--dark);
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
}

@media (max-width: 768px) {
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.question-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.question-box:hover {
    transform: scale(1.05);
}

.question-box.current {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}

.question-box.answered {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
}

.question-box.unanswered {
    background: white;
    color: var(--dark);
}

/* Question Display */
.question-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.question-number {
    font-size: 1rem;
    color: var(--gray);
    margin-bottom: 10px;
}

.question-text {
    font-size: 1.3rem;
    line-height: 1.6;
    margin-bottom: 25px;
}

.options-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .options-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

.option {
    padding: 15px 20px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.option:hover {
    background: #f9fafb;
    border-color: var(--primary);
}

.option.selected {
    background: #e0e7ff;
    border-color: var(--primary);
    color: var(--primary);
}

.option.correct {
    background: #d1fae5;
    border-color: var(--secondary);
    color: #065f46;
}

.option.incorrect {
    background: #fee2e2;
    border-color: var(--danger);
    color: #991b1b;
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--border);
    border-radius: 50%;
    margin-right: 15px;
    font-weight: 600;
}

.option.selected .option-letter {
    background: var(--primary);
    color: white;
}

.option.correct .option-letter {
    background: var(--secondary);
    color: white;
}

.option.incorrect .option-letter {
    background: var(--danger);
    color: white;
}

/* Navigation Buttons */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
}

.nav-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.prev-btn {
    background: #f3f4f6;
    color: var(--dark);
}

.prev-btn:hover {
    background: #e5e7eb;
}

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

.next-btn:hover {
    background: var(--primary-dark);
}

.finish-btn {
    background: var(--secondary);
    color: white;
}

.finish-btn:hover {
    background: #0da271;
}

/* Modal / Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray);
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: #f3f4f6;
}

.modal-body {
    padding: 25px;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-select, .form-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    display: none;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: toastSlideIn 0.3s ease;
}

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

.toast-success {
    background: var(--secondary);
}

.toast-error {
    background: var(--danger);
}

.toast-warning {
    background: var(--warning);
}

.toast-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

/* Ad Container */
.ad-container {
    width: 100%;
    height: 250px;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    margin: 30px auto;
    font-weight: 500;
    position: relative;
}

.ad-label {
    position: absolute;
    top: -12px;
    left: 15px;
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Explanation Modal Styles */
.explanation-modal-content {
    max-width: 500px;
    background: white;
}

.explanation-result {
    text-align: center;
    margin: 20px 0 30px;
    padding: 20px;
    border-radius: 10px;
    background: #f8f9fa;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.result-icon.correct {
    color: var(--secondary);
}

.result-icon.incorrect {
    color: var(--danger);
}

.result-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--dark);
}

.explanation-content {
    background: #f1f5f9;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-left: 4px solid var(--primary);
}

.explanation-content h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.explanation-content p {
    line-height: 1.6;
    color: var(--dark);
}

.explanation-actions {
    display: flex;
    justify-content: center;
    margin-top: 25px;
}

#continueQuizBtn {
    padding: 12px 30px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Update modal title for explanation */
#explanationTitle {
    display: flex;
    align-items: center;
    gap: 10px;
}

#explanationTitle.correct {
    color: var(--secondary);
}

#explanationTitle.incorrect {
    color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 15px;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
    
    .home-title {
        font-size: 2rem;
    }
    
    .take-quiz-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
    }
    
    .quiz-grid, .topic-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .subject-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .quiz-card, .topic-card {
        padding: 20px;
    }
    
    .quiz-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .modal {
        max-height: 80vh;
    }
    
    .question-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .ad-container {
        height: 200px;
    }
    
    .explanation-modal-content {
        max-width: 90%;
    }
    
    .result-icon {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .loading-title {
        font-size: 2rem;
    }
    
    .loading-subtitle {
        font-size: 1.2rem;
    }
    
    .wave-progress {
        width: 250px;
    }
    
    .home-title {
        font-size: 1.8rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .quiz-grid, .topic-grid {
        grid-template-columns: 1fr;
    }
    
    .subject-list {
        grid-template-columns: 1fr;
    }
    
    .question-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .options-container {
        grid-template-columns: 1fr;
    }
    
    .nav-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-btn {
        width: 100%;
    }
}

/* Native Ad Styles */
.native-ad-card {
    grid-column: 1 / -1; /* Span full width of grid */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    margin: 20px 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.native-ad-label {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 2;
}

.native-ad-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    text-align: center;
    padding: 20px;
}

.native-ad-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--primary);
    opacity: 0.5;
}

.native-ad-placeholder p {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.native-ad-placeholder small {
    font-size: 0.8rem;
    color: var(--gray);
}

.native-ad-content {
    width: 100%;
    text-align: center;
}

/* Native Ad Container - This is what your ad script will target */
.native-ad-container {
    width: 100%;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile Responsive for Native Ads */
@media (max-width: 768px) {
    .native-ad-card {
        min-height: 200px;
        margin: 15px 0;
        padding: 15px;
    }
    
    .native-ad-container {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .native-ad-card {
        min-height: 180px;
        margin: 10px 0;
        padding: 10px;
    }
    
    .native-ad-container {
        min-height: 180px;
    }
}


/* Hidden class */
.hidden {
    display: none !important;
}