#gameOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    visibility: visible;
    opacity: 1;
}

#gameOverlay.hidden {
    display: none !important;
}

.gameBox {
    position: relative;
    width: 90%;
    margin-top: 20px;

    height: 80vh;            
    overflow-y: auto;          

    background: var(--primary);
    padding-top: 15px;
    padding-bottom: 5px;

    color: black;
    border-radius: 16px;
    border: 5px solid var(--nav-back);

    box-shadow:
        0 0 20px rgba(0, 255, 200, 0.25),
        inset 0 0 20px rgba(0, 255, 200, 0.08);

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 3vw, 30px);
}


.closeBtn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(255, 34, 34, 0.852);
    border: 1px solid rgba(255, 0, 0, 0.95);
    color: white;
}


.topandstat{
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    gap: clamp(8px, 2vw, 20px);
}


.topBar {
    display: flex;
    flex-direction: column;
    padding: 12px 15px;
    gap: 5px;
    background: rgba(255, 255, 255, 0.05);
    font-size: clamp(1rem, 1.5vw, 3rem);
    font-weight: bold;
    border-radius: 12px;

    border: 1px solid rgba(255, 255, 255, 0.08);

    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.topBar>h2, .statsPanel>h2{
    font-size: clamp(1rem, 1.5vw, 2rem);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-align: center;
}

.statsPanel {
    display: flex;
    flex-direction: column;
    font-size: clamp(1rem, 1.5vw, 3rem);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    gap: 5px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.correct {
    color: #22c55e;
    font-weight: bold;
}

.incorrect {
    color: #ef4444;
    font-weight: bold;
}

#gamename{
    text-align: center;
    font-size: clamp(1.5rem, 1.5vw, 2rem);
    color: var(--primary-blue);
    margin-bottom: 5px;
}

.qNo{
    font-size: clamp(0.8rem, 1.5vw, 1.5vw);
    font-weight: bold;
}


.questionCard .qNo{
    text-align: center;
    margin-bottom: 5px;
}


.questionCard #question {
    width: fit-content;
    max-width: 100%;
    min-width: 200px;  
    margin-bottom: 15px;    
    padding: 5px 10px ;
    background: linear-gradient(145deg, #1e293b, #0f172a);
    color: white;
    border-radius: 14px;
    text-align: center;
    border: 1px solid rgba(0, 255, 200, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 200, 0.1);
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.questionCard h2 {
    font-size: clamp(18px, 2vw, 28px);
    line-height: 1.4;
}


.optionsGrid{
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    gap: 10px;
}

.optionsGrid > button {
    width: fit-content;
    max-width: 100%;
    min-height: 50px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;

    background: var(--primary-blue);
    color: #fff;
    font-size: 16px;
    font-weight: 500;

    cursor: pointer;
    transition: all 0.25s ease;

    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
    white-space: normal;  
    word-break: break-word; 
    overflow-wrap: anywhere;
}

.optionsGrid > button:hover {
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(0, 255, 200, 0.6);
    box-shadow: 0 8px 20px rgba(0, 255, 200, 0.15);
}

.optionsGrid > button:active {
    transform: translateY(0px) scale(0.98);
}



/* ========================================
   RESULTS HEADER
   ======================================== */
.results-header {
    width: 100%;
    flex-shrink: 0;
    padding: 5px 0 15px 0;
    border-bottom: 2px solid #e9ecef;
}

.results-title {
    color: #2c3e50;
    text-align: center;
    margin: 0 0 18px 0;
    font-size: 26px;
    font-weight: 700;
}

/* ========================================
   STATS GRID
   ======================================== */
.results-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.stat-item {
    padding: 12px 10px;
    border-radius: 10px;
    text-align: center;
}

.stat-item-total {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
}

.stat-item-correct {
    background: #d4edda;
    border: 2px solid #28a745;
}

.stat-item-incorrect {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.stat-item-score {
    background: #fff3cd;
    border: 2px solid #ffc107;
}

.stat-item-percentage {
    background: #cce5ff;
    border: 2px solid #007bff;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-label-total {
    color: #6c757d;
}

.stat-label-correct {
    color: #155724;
}

.stat-label-incorrect {
    color: #721c24;
}

.stat-label-score {
    color: #856404;
}

.stat-label-percentage {
    color: #004085;
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: bold;
}

.stat-value-total {
    color: #2c3e50;
}

.stat-value-correct {
    color: #28a745;
}

.stat-value-incorrect {
    color: #dc3545;
}

.stat-value-score {
    color: #ffc107;
}

.stat-value-percentage {
    color: #007bff;
}

/* ========================================
   CLOSE RESULTS BUTTON
   ======================================== */
.close-results-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.close-results-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* ========================================
   QUESTIONS REVIEW
   ======================================== */
.questions-review {
    width: 100%;
    flex: 1;
    min-height: 150px;
    overflow-y: auto;
    padding: 12px 8px 0 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
    margin-top: 12px;
}

.review-question-item {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 2px solid;
    border-left-width: 5px;
    border-left-style: solid;
    box-sizing: border-box;
    flex-shrink: 0;
}

.review-question-item.correct {
    border-color: #28a745;
}

.review-question-item.incorrect {
    border-color: #dc3545;
}

.review-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 5px;
}

.review-question-number {
    margin: 0;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 700;
}

.review-question-status {
    font-weight: bold;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
}

.review-question-status.correct {
    background: #d4edda;
    color: #155724;
}

.review-question-status.incorrect {
    background: #f8d7da;
    color: #721c24;
}

.review-question-text {
    font-size: 14px;
    margin: 4px 0 8px 0;
    color: #495057;
    font-weight: 500;
}

.review-options-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.review-option-item {
    padding: 5px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.review-option-item.correct-option {
    background: #d4edda;
    border: 2px solid #28a745;
}

.review-option-item.wrong-selection {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

.review-option-label {
    font-weight: 600;
    color: #495057;
    min-width: 20px;
    font-size: 12px;
}

.review-option-text {
    flex: 1;
    color: #333;
    font-size: 12px;
}

.review-option-indicator {
    margin-left: auto;
    font-size: 12px;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
.questions-review::-webkit-scrollbar {
    width: 6px;
}

.questions-review::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.questions-review::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.questions-review::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* ========================================
   REVIEW QUESTION ITEMS
   ======================================== */
.review-question-item {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 2px solid;
    border-left-width: 5px;
    border-left-style: solid;
    box-sizing: border-box;
    flex-shrink: 0;
}

.review-question-item.correct {
    border-color: #28a745;
}

.review-question-item.incorrect {
    border-color: #dc3545;
}

/* Question Header - Question number and text on same line */
.review-question-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.review-question-number {
    margin: 0;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.review-question-text {
    margin: 0;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 700;
}

/* Options List */
.review-options-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}


/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Tablets */
@media screen and (max-width: 768px) {
    .results-title {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .results-stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 8px;
        margin-bottom: 12px;
    }

    .stat-item {
        padding: 8px 6px;
        border-radius: 8px;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .close-results-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .questions-review {
        min-height: 120px;
        padding: 10px 5px 0 0;
        gap: 8px;
        margin-top: 10px;
    }

    .review-question-item {
        padding: 10px 14px;
        border-left-width: 4px;
    }

    .review-question-number {
        font-size: 13px;
    }

    .review-question-status {
        font-size: 10px;
        padding: 2px 8px;
    }

    .review-question-text {
        font-size: 13px;
        margin: 3px 0 6px 0;
    }

    .review-option-item {
        padding: 4px 8px;
        font-size: 12px;
        gap: 6px;
    }

    .review-option-label {
        font-size: 11px;
        min-width: 18px;
    }

    .review-option-text {
        font-size: 11px;
    }

    .review-option-indicator {
        font-size: 11px;
    }
}

/* Mobile Phones */
@media screen and (max-width: 480px) {
    .results-title {
        font-size: 17px;
        margin-bottom: 10px;
    }

    .results-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
        margin-bottom: 10px;
    }

    .stat-item {
        padding: 6px 4px;
        border-radius: 6px;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .close-results-btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }

    .questions-review {
        min-height: 100px;
        padding: 8px 3px 0 0;
        gap: 6px;
        margin-top: 8px;
    }

    .review-question-item {
        padding: 8px 10px;
        border-left-width: 3px;
    }

    .review-question-number {
        font-size: 11px;
    }

    .review-question-status {
        font-size: 9px;
        padding: 1px 6px;
    }

    .review-question-text {
        font-size: 11px;
        margin: 2px 0 4px 0;
    }

    .review-options-list {
        gap: 3px;
    }

    .review-option-item {
        padding: 3px 6px;
        font-size: 10px;
        gap: 4px;
        border-radius: 3px;
    }

    .review-option-label {
        font-size: 9px;
        min-width: 15px;
    }

    .review-option-text {
        font-size: 10px;
    }

    .review-option-indicator {
        font-size: 10px;
    }
}

/* Extra Small Phones */
@media screen and (max-width: 360px) {
    .results-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }

    .results-title {
        font-size: 15px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.5rem;
    }
}