body {
    background: #090909;
}

body.quiz-active {
    overflow: hidden;
    /* Prevent scrolling of the main page behind the quiz */
}

/* Make the quiz cards act as fixed overlays */
.quiz-card {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(9, 9, 9, 0.95);
    /* Dark, semi-transparent background */
    z-index: 1000;
    display: none;
    /* Keep hidden by default */
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* A new inner container to constrain the width and allow scrolling */
.quiz-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background-color: var(--card-bg-color);
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

#quiz-game-area .quiz-card-inner {
    padding-top: 60px;
    /* Make space for the absolute positioned HUD */
}

.exit-quiz-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}

.exit-quiz-btn:hover {
    color: #fff;
}

.frontpage-container {
    min-height: 100vh;
}

.main-content {
    display: flex;
    justify-content: center;
}

.quiz-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    box-sizing: border-box;
    text-align: center;
}

.quiz-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background-color: var(--card-bg-color);
    padding: 30px;
    border-radius: 8px;
    flex: 1;
}

.quiz-button {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    background-color: var(--button-background-light);
    color: white;
    border: none;
    padding: 16px;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.3s;
}

.quiz-button:hover {
    background-color: #444;
}

.quiz-button.secondary {
    background-color: #444;
}

.quiz-button.secondary:hover {
    background-color: #666;
}

.quiz-button.tertiary {
    background-color: transparent;
    border: 1px solid #555;
}

.quiz-button.tertiary:hover {
    background-color: var(--button-background-light);
}

.quiz-mode-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: -7px;
}

.shared-quiz-section {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
}

#load-shared-quiz {
    width: 48px;
    border-radius: 12px;
    background-color: #f26347;
    border: none;
    color: #fff;
    cursor: pointer;
}

.shared-quiz-section input {
    color: var(--text-primary-color);
    display: flex;
    flex: 1;
    height: 16px;
    padding: 16px;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 8px;
    outline: none;
    border: none;
    border-radius: 12px;
    background: #282828;
    transition: all 0.2s ease;
}

.shared-quiz-section input:focus {
    border-color: #555;
    background-color: #333;
}

.shared-quiz-section input::placeholder {
    color: #8D8C8C;
}

/* Settings Card */
.setting-section {
    margin-bottom: 30px;
    border-top: 1px solid #444;
    padding-top: 20px;
    width: 100%;
    color: #fff;
}

.setting-section h3 {
    margin-top: 0;
}

.selection-presets {
    margin-bottom: 15px;
}

.selection-presets button {
    background-color: var(--button-background-light);
    border: 1px solid #555;
    color: #ccc;
    padding: 5px 10px;
    margin: 2px;
    cursor: pointer;
    border-radius: 4px;
}

.selection-presets button:hover {
    background: #444;
}

.platform-selection,
.genre-selection {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.platform-item,
.genre-item {
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    border: 2px solid #444;
    transition: all 0.2s;
}

.platform-item {
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.platform-item:hover,
.genre-item:hover {
    background-color: #3f3f3f;
}

.platform-item.selected,
.genre-item.selected {
    background-color: #e64a19;
    border-color: #fff;
}

.platform-item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 8px;
}

.genre-item {
    padding: 8px 15px;
}

/* Sliders */
.sliders-normal,
.sliders-endless,
.other-settings {
    display: flex;
    gap: 40px;
    max-width: 100%;
    margin: 0 auto;
    text-align: left;
    flex-direction: column;
}

.sliders-normal label,
.sliders-endless label,
.other-settings label {
    display: block;
    margin: 15px 0 5px;
}

.ui-slider {
    background: #444;
    border: 1px solid #555;
}

.ui-slider-handle {
    background: #e64a19;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
}

.ui-slider-handle:focus {
    outline: none;
}

.ui-slider-range {
    background: #f57c00;
}

.ui-slider-handle .ui-slider-tip {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #111;
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 12px;
    white-space: nowrap;
}

/* --- Gameplay Area --- */

#quiz-game-area {
    position: fixed;
    width: 100%;
}

#daily-completed-history {
    color: #FFF;
}

.game-hud {
    position: absolute;
    top: 15px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: bold;
    color: #ccc;
}

.score {
    position: relative;
    transition: transform 0.2s ease-out, color 0.2s ease-out;
}

.score.score-updating {
    transform: scale(1.2);
    color: #ffc107;
}

#bonus-points-display {
    position: absolute;
    left: 105%;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    font-weight: bold;
    opacity: 0;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 8px;
    border-radius: 5px;
}

#bonus-points-display .base-points {
    color: #fff;
}

#bonus-points-display .bonus-points {
    color: #4CAF50;
    font-size: 0.9em;
}


#bonus-points-display.show-bonus {
    animation: bonus-pop 1.2s ease-out forwards;
}

@keyframes bonus-pop {
    0% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-150%) scale(1.2);
    }
}

/* Card container */
.card {
    width: 100%;
    min-height: 500px;
    /* Use min-height to allow content to expand if needed */
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}


/* Question Content Styling */
.question-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.question-image-container {
    min-height: 250px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
}

.image-loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #e64a19;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    position: absolute;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.question-image {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: 5px;
}

.question-content h3 {
    font-size: 1.5rem;
    margin-bottom: 25px;
}

.alternatives-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.alternative {
    background-color: #444;
    color: white;
    border: 2px solid #555;
    padding: 15px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.alternative:hover {
    background-color: #555;
    border-color: #999;
}

/* Special styles for Either/Or questions */
.alternative.either-or {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.alternative.either-or img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 4px;
}


/* Answer Feedback */
.alternative.correct {
    background-color: #4CAF50;
    /* Green */
    border-color: #fff;
    transform: scale(1.05);
}

.alternative.wrong {
    background-color: #F44336;
    /* Red */
    border-color: #fff;
    opacity: 0.7;
}

.alternatives-container.answered .alternative:not(.correct):not(.wrong) {
    opacity: 0.5;
    pointer-events: none;
}

.platform-reveal-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 0px 0px 20px;
    height: 100px;
    /* Set a fixed height */
}

.platform-reveal-slot {
    width: 100px;
    height: 100px;
    background-color: #1a1a1a;
    border: 2px solid #555;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 10px #000;
}

.platform-reveal-slot img {
    width: 80%;
    height: 80%;
    position: absolute;
    top: 10%;
    left: 10%;
    object-fit: contain;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    /* For the 'thud' effect */
}

.platform-reveal-slot img.revealed {
    transform: scale(1.1);
}

.lives {
    display: flex;
    gap: 8px;
    /* Adds space between hearts */
}

.fa-icon {
    font-size: 28px;
    /* Makes hearts bigger */
    color: #ff4757;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.heart-lost {
    animation: heart-explode 0.5s ease-out forwards;
}

@keyframes heart-explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(0.5);
        opacity: 0;
    }
}

.timer-container {
    width: 100%;
    margin-top: 10px;
}

.timer-label {
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 4px;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

#timer-bar-inner {
    height: 100%;
    width: 100%;
    background-color: #4CAF50;
    border-radius: 4px;
    transition: width 0.1s linear;
}

#quiz-game-over-card .game-over-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

#share-link-container {
    margin-top: 20px;
    text-align: center;
}

#share-link-input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    text-align: center;
}

/* --- NEW MODAL STYLES --- */
.selection-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.selection-modal-content {
    background-color: #2a2a2a;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px;
    border-radius: 8px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.selection-modal-body {
    overflow-y: auto;
    padding-right: 15px;
}

.selection-modal-footer {
    padding-top: 20px;
    text-align: right;
}

.selected-display {
    background-color: var(--button-background-light);
    border: 1px solid #555;
    border-radius: 5px;
    padding: 10px;
    min-height: 40px;
    color: #ccc;
    text-align: left;
    margin-bottom: 10px;
}

.change-selection-btn {
    margin-left: 10px;
}

#daily-quiz-history {
    color: #FFF;
}

/* Quiz selector */


/* --- Mobile Responsiveness --- */
.mobile-layout {
    display: none;
}

@media (max-width: 768px) {
    .desktop-layout {
        display: none;
    }

    .mobile-layout {
        display: block;
        padding: 10px;
    }

    .mobile-layout .frontpage-main-content {
        padding: 10px;
    }

    .mobile-quiz-mode-selection {
        display: flex;
        gap: 10px;
        margin-bottom: 20px;
        justify-content: space-around;
    }

    .mobile-quiz-mode-selection .quiz-button {
        flex: 1;
        padding: 12px 8px;
        font-size: 13px;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        min-height: 70px;
    }

    .mobile-layout .articles-list-wrapper {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* Quiz Card Adjustments */
    .quiz-card-inner {
        padding: 20px;
        max-height: 95vh;
    }

    .quiz-card {
        padding: 50px 30px 30px 30px;
    }

    #quiz-game-area .quiz-card-inner {
        padding-top: 50px;
    }

    .game-hud {
        font-size: 0.9rem;
        top: 10px;
        left: 10px;
        right: 10px;
        align-items: center;
    }

    .exit-quiz-btn {
        top: 5px;
        right: 5px;
        font-size: 2rem;
    }

    .card {
        min-height: 400px;
    }

    .question-content h3 {
        font-size: 1.2rem;
    }

    .alternatives-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .alternative {
        font-size: 0.9rem;
        padding: 12px;
    }

    #quiz-game-over-card .game-over-actions {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    #quiz-game-over-card .game-over-actions .quiz-button {
        box-sizing: border-box;
    }

    .question-image-container {
        min-height: 200px;
        width: 100%;
    }

    .setting-section {
        padding-top: 15px;
        margin-bottom: 20px;
    }

    .quiz-starter-container .quiz-button {

        justify-content: center;
    }

    .platform-reveal-container {
        flex-wrap: wrap;
        height: auto;
    }

    #reveal-title {
        text-align: center;
    }
}