* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 0.4s ease; /* Smooth theme transition */
}

/* ✅ Light Theme (default) */
body.light-theme {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #333;
}

/* ✅ Dark Theme */
body.dark-theme {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #e1e1e1;
}

.screen {
    display: none;
    width: 100%;
    max-width: 800px;
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.5s ease-in-out;
    transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}

body.dark-theme .screen {
    background: #1a1a2e;
    color: #e1e1e1;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    text-align: center;
}

h1, h2, h3 {
    margin-bottom: 20px;
    color: #333;
    transition: color 0.3s;
}

body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3 {
    color: #ffffff;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

input {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    background: white;
    color: #333;
    transition: border-color 0.3s, background 0.3s, color 0.3s;
}

body.dark-theme input {
    background: #2a2a3a;
    border-color: #4a4a6a;
    color: #ffffff;
}

input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    padding: 14px 28px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

ul {
    text-align: left;
    max-width: 500px;
    margin: 20px auto;
    line-height: 1.6;
    color: #555;
    transition: color 0.3s;
}

body.dark-theme ul {
    color: #ccc;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    font-weight: bold;
    font-size: 18px;
    color: #444;
    transition: color 0.3s;
}

body.dark-theme .quiz-header {
    color: #e0e0e0;
}

.quiz-container {
    text-align: center;
}

.question-box {
    font-size: 22px;
    margin-bottom: 30px;
    min-height: 80px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 12px;
    transition: background 0.3s, color 0.3s;
}

body.dark-theme .question-box {
    background: #2a2a3a;
    color: #ffffff;
}

.options-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.option {
    padding: 16px;
    background: #f0f0f0;
    color: #333;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

body.dark-theme .option {
    background: #2a2a3a;
    color: #ffffff;
    border-color: transparent;
}

.option:hover {
    background: #e0e0e0;
    transform: scale(1.02);
}

body.dark-theme .option:hover {
    background: #3a3a4a;
}

.option.selected {
    background: #d0e0ff;
    border-color: #667eea;
}

body.dark-theme .option.selected {
    background: #3a3a6a;
    border-color: #667eea;
}

.hidden {
    display: none !important;
}

/* Score Circle */
.score-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(#667eea 0%, #667eea var(--p), #f0f0f0 var(--p), #f0f0f0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto;
    position: relative;
    font-weight: bold;
    font-size: 28px;
    color: #333;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transition: background 0.5s, color 0.3s;
}

body.dark-theme .score-circle {
    background: conic-gradient(#667eea 0%, #667eea var(--p), #2a2a3a var(--p), #2a2a3a 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    position: relative;
    animation: slideIn 0.4s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    padding-bottom: 60px;
    transition: background 0.3s, color 0.3s;
}

body.dark-theme .modal-content {
    background: #1a1a2e;
    color: #e1e1e1;
}

@keyframes slideIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

body.dark-theme .close {
    color: #ccc;
}

.answer-item {
    padding: 15px;
    margin: 10px 0;
    background: #f9f9f9;
    border-radius: 8px;
    text-align: left;
    transition: background 0.3s;
}

body.dark-theme .answer-item {
    background: #2a2a3a;
}

.user-answer {
    color: #d35400;
    font-weight: bold;
}

body.dark-theme .user-answer {
    color: #ff9f43;
}

.correct-answer {
    color: #27ae60;
    font-weight: bold;
}

body.dark-theme .correct-answer {
    color: #10ac84;
}

/* Go to Home Button */
#go-home-btn {
    margin-top: 20px;
    background: #e74c3c;
}

#go-home-btn:hover {
    background: #c0392b;
}

/* ✅ Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: none;
    border: 2px solid #667eea;
    color: #667eea;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: rotate(30deg);
}

body.dark-theme .theme-toggle {
    border-color: #667eea;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* ✅ Top Scores & Leaderboard Styles */
.top-scores, .leaderboard {
    margin-top: 30px;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.top-scores h3, .leaderboard h3 {
    margin-bottom: 15px;
    font-size: 18px;
    color: #555;
    text-align: center;
}

body.dark-theme .top-scores h3,
body.dark-theme .leaderboard h3 {
    color: #ccc;
}

.score-entry {
    padding: 12px 16px;
    background: #f0f0f0;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

body.dark-theme .score-entry {
    background: #2a2a3a;
}

.score-entry .rank {
    font-weight: bold;
    min-width: 30px;
    font-size: 16px;
}

.score-entry .name {
    flex: 1;
    padding-left: 10px;
}

.score-entry .score {
    font-weight: bold;
    color: #e74c3c;
    font-size: 16px;
}

body.dark-theme .score-entry .score {
    color: #ff6b6b;
}

/* Medal Styles */
.score-entry.top-1 {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.score-entry.top-1 .score {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.score-entry.top-2 {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6);
}

.score-entry.top-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: white;
}

.score-entry.top-1::before,
.score-entry.top-2::before,
.score-entry.top-3::before {
    margin-right: 8px;
    font-size: 18px;
}

/* Optional: Custom Scrollbar */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

body.dark-theme .modal-content::-webkit-scrollbar-track {
    background: #2a2a3a;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

body.dark-theme .modal-content::-webkit-scrollbar-thumb {
    background: #8e44ad;
}

/* Responsive */
@media (max-width: 768px) {
    .quiz-header {
        flex-direction: column;
        gap: 10px;
        font-size: 16px;
    }

    .score-circle {
        width: 160px;
        height: 160px;
        font-size: 22px;
    }

    button {
        padding: 12px 24px;
        font-size: 16px;
    }

    .question-box {
        font-size: 18px;
        padding: 15px;
    }

    .theme-toggle {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

/* Optional: Pulse animation for submit button */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

#submit-btn.pulse {
    animation: pulse 1.5s infinite;
}