/* ===== Root Variables ===== */
:root {
    --primary-color: #6366f1;
    --secondary-color: #ec4899;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-bg: #0f172a;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Background Animation ===== */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.3;
    animation: float 8s ease-in-out infinite;
}

.blob1 {
    width: 300px;
    height: 300px;
    background: #ec4899;
    top: -150px;
    left: -150px;
    animation-delay: 0s;
}

.blob2 {
    width: 250px;
    height: 250px;
    background: #06b6d4;
    bottom: -125px;
    right: -125px;
    animation-delay: 2s;
}

.blob3 {
    width: 200px;
    height: 200px;
    background: #fbbf24;
    top: 50%;
    right: 10%;
    animation-delay: 4s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0);
    }
    25% {
        transform: translate(30px, -30px);
    }
    50% {
        transform: translate(-20px, 20px);
    }
    75% {
        transform: translate(20px, 30px);
    }
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Screens ===== */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.5s ease forwards;
    width: 100%;
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Home Screen ===== */
.home-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.logo-section {
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 80px;
    color: var(--primary-color);
    display: block;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.logo-section h1 {
    font-size: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-weight: 800;
}

.logo-section p {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.welcome-text {
    margin-bottom: 40px;
}

.welcome-text h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.welcome-text p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.category-selection,
.difficulty-selection {
    margin-bottom: 40px;
    text-align: left;
}

.category-selection h3,
.difficulty-selection h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
}

.category-grid,
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.category-btn,
.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.category-btn i,
.difficulty-btn i {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.category-btn:hover,
.difficulty-btn:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.category-btn.selected,
.difficulty-btn.selected {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-color: transparent;
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.4);
}

.category-btn.selected i,
.difficulty-btn.selected i {
    color: white;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
    border-color: var(--primary-color);
}

.btn-lg {
    padding: 16px 40px;
    font-size: 18px;
    margin-top: 20px;
    width: 100%;
}

/* ===== Quiz Screen ===== */
.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.quiz-info {
    display: flex;
    gap: 10px;
}

.category-tag,
.difficulty-tag {
    display: inline-block;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.btn-quit {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-quit:hover {
    background: rgba(255, 0, 0, 0.3);
    transform: scale(1.1);
}

.quiz-progress {
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #06b6d4);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.quiz-container {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.question-section {
    margin-bottom: 40px;
}

.question-text {
    font-size: 24px;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
    font-weight: 700;
}

.fun-fact {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border-left: 4px solid var(--primary-color);
    padding: 15px 20px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    display: none;
    margin-top: 15px;
}

.fun-fact.show {
    display: block;
    animation: slideIn 0.3s ease;
}

.options-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-weight: 500;
}

.option-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
    color: var(--text-primary);
}

.option-btn.selected {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border-color: var(--primary-color);
}

.option-btn.selected .option-letter {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.option-btn.correct {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border-color: var(--success-color);
}

.option-btn.correct .option-letter {
    background: var(--success-color);
}

.option-btn.wrong {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    border-color: var(--danger-color);
}

.option-btn.wrong .option-letter {
    background: var(--danger-color);
}

.option-btn:disabled {
    cursor: not-allowed;
}

.quiz-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.stat {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.stat i {
    font-size: 20px;
    color: var(--primary-color);
}

.stat strong {
    color: var(--text-primary);
    font-size: 18px;
}

/* ===== Result Screen ===== */
.result-container {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 50px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.result-icon {
    font-size: 100px;
    margin-bottom: 30px;
    animation: bounce 2s ease-in-out infinite;
}

.result-title {
    font-size: 36px;
    color: var(--text-primary);
    margin-bottom: 15px;
    font-weight: 800;
}

.result-message {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.6;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.stat-box {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid var(--border-color);
}

.stat-number {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}

.result-feedback {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border-left: 4px solid var(--primary-color);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: left;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.button-group .btn {
    flex: 1;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    font-weight: 600;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--card-bg);
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    opacity: 0;
    transform: translateX(400px);
    transition: var(--transition);
    z-index: 999;
    font-weight: 600;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
    color: var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
    color: var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
    color: var(--info-color);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .home-content,
    .quiz-container,
    .result-container {
        padding: 25px;
    }

    .logo-icon {
        font-size: 60px;
    }

    .logo-section h1 {
        font-size: 36px;
    }

    .category-grid,
    .difficulty-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .question-text {
        font-size: 18px;
    }

    .option-btn {
        padding: 15px;
        gap: 15px;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .quiz-stats {
        grid-template-columns: 1fr;
    }

    .toast {
        bottom: 20px;
        right: 20px;
        left: 20px;
    }
}

@media (max-width: 480px) {
    .logo-section h1 {
        font-size: 28px;
    }

    .welcome-text h2 {
        font-size: 22px;
    }

    .question-text {
        font-size: 16px;
    }

    .result-title {
        font-size: 28px;
    }

    .stat-number {
        font-size: 28px;
    }
}

/* ===== Admin Link ===== */
.admin-link-corner {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    text-decoration: none;
    font-size: 20px;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.admin-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1) rotate(90deg);
}

@media (max-width: 768px) {
    .admin-link-corner {
        top: 15px;
        right: 15px;
    }

    .admin-link {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}
