/* ~~~~~~~~~~~~~~ GENERAL STYLING ~~~~~~~~~~~~~~ */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --background-color: #f4f7f6;
    --text-color: #333;
    --light-text-color: #fff;
    --card-bg-color: #ffffff;
    --correct-color: #28a745;
    --incorrect-color: #dc3545;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --font-family: 'Helvetica Neue', Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

#game-container {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.card {
    background-color: var(--card-bg-color);
    border-radius: var(--border-radius);
    padding: 30px 40px;
    box-shadow: 0 10px 25px var(--shadow-color);
    text-align: center;
}

.title {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 30px;
}

/* ~~~~~~~~~~~~~~ BUTTONS & FORMS ~~~~~~~~~~~~~~ */
.btn {
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 5px;
    min-width: 150px;
}

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

.primary-btn:hover {
    background-color: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.secondary-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.secondary-btn:hover {
    background-color: var(--primary-color);
    color: var(--light-text-color);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

select, input[type="text"] {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
    box-sizing: border-box;
}

/* ~~~~~~~~~~~~~~ LOADER ~~~~~~~~~~~~~~ */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* ~~~~~~~~~~~~~~ GAME SCREEN & HUD ~~~~~~~~~~~~~~ */
#game-hud {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.hud-prefix {
    font-size: 1rem;
    color: #888;
}

.hud-main-text {
    font-size: 2rem;
    margin-top: 5px;
}

#score-hud {
    text-align: right;
}

#progress-text {
    margin-bottom: 5px;
}

#progress-bar {
    width: 200px;
    height: 20px;
    background-color: #eee;
    border-radius: 10px;
    overflow: hidden;
}

#progress-bar-full {
    height: 100%;
    width: 0%;
    background-color: var(--secondary-color);
    transition: width 0.3s ease-in-out;
}

#timer {
    width: 100%;
    height: 10px;
    background-color: #eee;
    border-radius: 5px;
    margin-bottom: 20px;
    overflow: hidden;
}

#timer-bar {
    height: 100%;
    width: 100%;
    background-color: var(--secondary-color);
    transition: width 0.1s linear;
}

#question-text {
    font-size: 1.5rem;
    margin-bottom: 30px;
    min-height: 80px;
}

.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.answer-btn {
    background-color: var(--light-text-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    text-align: left;
    padding: 15px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.answer-btn:hover:not([disabled]) {
    background-color: var(--primary-color);
    color: var(--light-text-color);
}

.answer-btn.correct {
    background-color: var(--correct-color);
    border-color: var(--correct-color);
    color: var(--light-text-color);
}

.answer-btn.incorrect {
    background-color: var(--incorrect-color);
    border-color: var(--incorrect-color);
    color: var(--light-text-color);
}

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

#next-question-btn {
    margin-top: 20px;
}

/* ~~~~~~~~~~~~~~ RESULTS & REVIEW ~~~~~~~~~~~~~~ */
#final-score {
    color: var(--primary-color);
}

#score-breakdown {
    margin: 30px 0;
    line-height: 1.8;
    font-size: 1.1rem;
}

#high-score-form {
    margin: 20px 0;
}

#high-score-form input {
    margin-bottom: 10px;
}

#results-buttons {
    margin-top: 20px;
}

#review-content {
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 15px;
}

.review-item {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.review-item p {
    font-weight: bold;
}

.review-item .user-answer.correct {
    color: var(--correct-color);
}

.review-item .user-answer.incorrect {
    color: var(--incorrect-color);
}

.review-item .correct-answer {
    color: var(--correct-color);
}

/* ~~~~~~~~~~~~~~ LEADERBOARD ~~~~~~~~~~~~~~ */
.filter-container {
    margin-bottom: 20px;
    text-align: right;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

#leaderboard-table th, #leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#leaderboard-table th {
    background-color: #f8f8f8;
    font-weight: bold;
}

#leaderboard-table tr:hover {
    background-color: #f1f1f1;
}

/* ~~~~~~~~~~~~~~ UTILITY & RESPONSIVE ~~~~~~~~~~~~~~ */
.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .card {
        padding: 20px;
    }

    .title {
        font-size: 2rem;
    }

    .answer-grid {
        grid-template-columns: 1fr;
    }

    #game-hud {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    #score-hud {
        text-align: center;
    }
}