:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.light-mode {
    --bg-dark: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
}

.light-mode .btn-secondary {
    background: #e2e8f0;
    color: var(--text-main);
    border-color: #cbd5e1;
}

.light-mode .btn-secondary:hover:not(:disabled) {
    background: #cbd5e1;
}

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

.light-mode .btn:disabled {
    opacity: 0.4;
    background: #f1f5f9;
    color: #94a3b8;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: background-color 0.5s ease, color 0.5s ease;
}

/* Background Blobs */
.blob {
    position: absolute;
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    filter: blur(80px);
    opacity: 0.15;
    z-index: -1;
    border-radius: 50%;
}

.blob-1 {
    top: -10%;
    left: -10%;
    animation: float 20s infinite alternate;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    animation: float 25s infinite alternate-reverse;
}

@keyframes float {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(100px, 50px) scale(1.1);
    }
}

/* Container & Card */
.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    z-index: 10;
}

.quiz-card {
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    min-height: 450px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.5s ease-out;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hero Section */
.hero-content {
    text-align: center;
    max-width: 500px;
    margin: auto;
}

.icon-wrapper {
    background: rgba(99, 102, 241, 0.1);
    width: 120px;
    height: 120px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-muted);
    font-size: 1.125rem;
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem 2rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Setup Screen */
.setup-content h2 {
    text-align: center;
    margin-bottom: 2.5rem;
    font-size: 2rem;
}

.setup-group {
    margin-bottom: 2rem;
}

.setup-group label {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.select-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.select-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}

.select-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#start-quiz-btn {
    width: 100%;
    margin-top: 1rem;
}

/* Quiz Header Stats */
.quiz-stats {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* Circular Timer */
#timer-container {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 3;
}

.timer-bar {
    fill: none;
    stroke: var(--secondary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 113;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

#time-left {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.timer-warning .timer-bar {
    stroke: #ef4444;
}

/* Lifelines */
.quiz-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.lifelines {
    display: flex;
    gap: 0.75rem;
}

.lifeline-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.lifeline-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.lifeline-btn:disabled {
    opacity: 0.2;
    cursor: not-allowed;
    filter: grayscale(1);
}

.lifeline-icon {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Question & Explanation */
.explanation-box {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--primary);
    border-radius: 0 12px 12px 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    animation: slideIn 0.3s ease-out;
}

.hidden {
    display: none !important;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Question & Options */
#question-text {
    font-size: 1.5rem;
    line-height: 1.4;
    margin-bottom: 2rem;
    font-weight: 600;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.option-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 1.25rem;
    border-radius: 16px;
    color: var(--text-main);
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
}

.option-btn.selected {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    color: white;
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* Results */
.result-content {
    text-align: center;
    margin: auto;
}

.result-icon-wrapper {
    background: rgba(16, 185, 129, 0.1);
    width: 100px;
    height: 100px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: #10b981;
}

.score-card {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 2rem;
    margin: 1.5rem 0 2rem;
}

.score-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 3rem;
    font-weight: 700;
    color: white;
}

#result-message {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 640px) {
    .options-grid {
        grid-template-columns: 1fr;
    }

    .quiz-card {
        padding: 1.5rem;
    }

    h1 {
        font-size: 2.25rem;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.loader {
    width: 40px;
    height: 40px;
    border: 4px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Theme Toggle */
.theme-btn {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    color: var(--text-main);
    cursor: pointer;
    backdrop-filter: blur(var(--glass-blur));
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-btn:hover {
    transform: rotate(15deg);
}

/* Leaderboard */
.leaderboard-list {
    margin: 2rem 0;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
}

.rank-tag {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 1rem;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
}

.entry-details {
    text-align: right;
}

.entry-score {
    font-weight: 700;
    color: var(--primary);
}

.entry-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    padding: 0.5rem;
    border-radius: 8px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}