/* Flash Animations for Feedback */
@keyframes flash-correct {
    0%, 100% {
        background-color: transparent;
        border-color: transparent;
    }
    50% {
        background-color: rgba(76, 175, 80, 0.2);
        border: 3px solid #4caf50;
    }
}

@keyframes flash-wrong {
    0%, 100% {
        background-color: transparent;
        border-color: transparent;
    }
    50% {
        background-color: rgba(244, 67, 54, 0.2);
        border: 3px solid #f44336;
    }
}

.content-card.flash-correct {
    animation: flash-correct 0.6s ease;
}

.content-card.flash-wrong {
    animation: flash-wrong 0.6s ease;
}

/* Settings pills grid - compact layout */
.tables-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

/* Default pill size (for sub-settings) */
.table-pill {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 200px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Main settings pills - slightly larger */
.table-pill[data-setting-id]:not([data-subsetting-id]) {
    width: 220px;
    height: 160px;
}

.table-pill .table-number {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.table-pill .table-label {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.table-pill:hover:not(.active) {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--feature-shadow);
}

/* Active state */
.table-pill.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px var(--btn-shadow);
}

.table-pill.active .table-number,
.table-pill.active .table-label {
    color: white;
}

.btn-quick {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-quick:hover:not(.active) {
    background: rgba(var(--primary-color-rgb, 190, 213, 88), 0.1);
    transform: translateY(-2px);
}

.btn-quick.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--btn-shadow);
}

.quick-select-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

/* Summary Score Display */
.summary-score {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(135deg, var(--summary-bg-start), var(--summary-bg-end));
    border-radius: 1rem;
    margin-bottom: 2rem;
}

.score-circle {
    display: inline-block;
    margin-bottom: 2rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.score-label {
    font-size: 1.25rem;
    color: #666;
    font-weight: 600;
    margin-top: 0.5rem;
}

.score-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.score-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.stat-text {
    font-size: 0.95rem;
    color: #666;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Question Review Items */
/* Question Review Items - additional styles */
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Main Exercise Title (larger than section-title) */
.exercise-main-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1.5rem;
}

.exercise-main-title i {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.review-number {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
}

.review-status {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
}

.review-status.correct {
    background: #d1fae5;
    color: #047857;
}

.review-status.incorrect {
    background: #fee2e2;
    color: #dc2626;
}

.review-question {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1rem;
    font-family: 'Courier New', Consolas, monospace;
}

.review-answer,
.review-correct {
    color: #666;
    margin-bottom: 0.5rem;
}

.review-correct {
    color: #047857;
}

.review-explanation {
    background: #f0f9ff;
    border-left: 3px solid #3b82f6;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    border-radius: 0.25rem;
    font-size: 0.95rem;
    color: #1e40af;
}

/* Subsetting container */
.subsetting-container {
    margin-top: 1.5rem;
}

/* Timer low warning */
.timer-low .stat-value {
    animation: pulse-timer 1s infinite;
    color: #dc2626;
}

@keyframes pulse-timer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Answer input for text-based games */
.answer-box {
    max-width: 500px;
    margin: 0 auto 1rem;
}

.answer-input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.5rem;
    text-align: center;
    border: 3px solid #e9ecef;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: 'Courier New', Consolas, monospace;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem var(--focus-shadow);
}

/* Remove number input spinners */
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.answer-input[type=number] {
    -moz-appearance: textfield;
}

/* Submit button for answer-based games */
.btn-submit {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 0.875rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--btn-shadow);
    display: block;
    margin: 0 auto;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--btn-shadow);
}

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

/* Feedback icon positioning */
.feedback-icon {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.5rem;
}

/* Question container */
.question-container {
    text-align: center;
    margin-bottom: 1rem;
}

/* Constrain images within questions to fit viewport */
.question-container img,
.question-display img {
    max-height: 280px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.question-display {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.75rem;
    font-family: 'Courier New', Consolas, monospace;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

/* Game area */
.game-area {
    padding: 1rem 0;
}

/* Instructions box (pre-start) */
.instructions-box {
    text-align: center;
    padding: 3rem 2rem;
}

.instructions-box h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1rem;
}

.instructions-box p {
    font-size: 1.15rem;
    color: #666;
    margin-bottom: 2rem;
}

.btn-play {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 1.25rem 3rem;
    font-size: 1.35rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--btn-shadow);
}

.btn-play:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--btn-shadow);
}

/* Secondary button styling */
.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-2px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .question-display {
        font-size: 1.25rem;
    }

    .score-value {
        font-size: 3rem;
    }

    .stat-number {
        font-size: 2rem;
    }

    .score-stats {
        gap: 1.5rem;
    }

    .answer-input {
        font-size: 1.15rem;
        padding: 0.875rem;
    }

    .btn-submit {
        font-size: 1rem;
        padding: 0.75rem 1.75rem;
    }

    .question-container img,
    .question-display img {
        max-height: 200px;
    }
}

/* Answer Grid Layout */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

/* Individual Answer Button */
.answer-option {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 70px;
    font-size: 1.1rem;
}

.answer-option:hover:not(:disabled) {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--feature-shadow);
}

/* Answer Letter Circle (A, B, C, D) */
.answer-letter {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Answer Value Text */
.answer-value {
    flex: 1;
    text-align: left;
    color: #1a1a1a;
    font-weight: 500;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 1.2rem;
}

/* Disabled State */
.answer-option:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Correct Answer State */
.answer-option.correct {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4caf50;
}

.answer-option.correct .answer-letter {
    background: #4caf50;
}

/* Incorrect Answer State */
.answer-option.incorrect {
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid #f44336;
}

.answer-option.incorrect .answer-letter {
    background: #f44336;
}

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

    .answer-option {
        padding: 1rem;
        min-height: 60px;
    }

    .answer-letter {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .answer-value {
        font-size: 1rem;
    }
}

.summary-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

.summary-left,
.summary-right {
    display: flex;
    flex-direction: column;
}

/* Both boxes use same height and styling */
.summary-box,
.share-section {
    height: 100%;
}

/* Share section - center the text content */
.share-section {
    text-align: center;
}

.share-heading {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.share-heading i {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.share-description {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Share Button - Styled like hero button */
.btn-share-settings {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--btn-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-share-settings:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--btn-shadow);
}

.btn-share-settings:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-share-settings i {
    font-size: 1.3rem;
}

/* Start button - full width below summary */
#summaryCard .btn-start-quiz {
    width: 100%;
    margin-top: 0;
}

/* Mobile Responsive */
@media (max-width: 992px) {
    .summary-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .share-section {
        padding: 1.5rem;
    }

    .share-heading {
        font-size: 1.2rem;
    }

    .share-description {
        font-size: 0.95rem;
    }

    .btn-share-settings {
        font-size: 1rem;
        padding: 0.875rem 2rem;
    }
}

/* ===== EXERCISE-SPECIFIC STYLES ===== */

/* Image Lightbox */
.image-lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

.image-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
    animation: zoomIn 0.3s ease;
}

.lightbox-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: 0.3s;
    background: rgba(0, 0, 0, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.question-image-clickable {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.question-image-clickable:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

/* Explanation Content */
.explanation-content {
    background: #f8f9fa;
    border-left: 4px solid #0066cc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.explanation-content:empty {
    display: none;
}

.explanation-image {
    text-align: center;
    margin-bottom: 1rem;
}

.explanation-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.explanation-image:empty {
    display: none;
}

/* Explanation Button */
.btn-explanation {
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    margin-left: auto;
}

.btn-explanation:hover {
    background: #0052a3;
    transform: scale(1.1);
}

/* Review Header */
.review-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #28a745;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
    z-index: 10000;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-notification i {
    font-size: 1.25rem;
}

/* Difficulty Indicator */
.difficulty-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.difficulty-stars {
    display: flex;
    gap: 3px;
    font-size: 1.1rem;
}

.difficulty-stars i {
    color: #d1d5db;
}

.difficulty-stars i.filled {
    color: #fbbf24;
}

/* Ensure content-card is positioned relative */
#gameCard {
    position: relative;
}

@media (max-width: 768px) {
    .difficulty-indicator {
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .difficulty-stars {
        font-size: 0.95rem;
        gap: 2px;
    }
}
/* ===== FRACTION INPUT STYLES ===== */

.fraction-answer-area {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2rem 0;
    min-height: 120px;
}

/* Wrapper for proper/improper fraction (2 boxes) */
.fraction-input-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Stacked numerator + bar + denominator */
.fraction-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* Mixed number wrapper: whole number + fraction side by side */
.mixed-number-wrapper {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    justify-content: center;
}

/* The whole number input in a mixed number */
.fraction-box.fraction-whole {
    align-self: center;
}

/* Individual number input box */
.fraction-box {
    width: 80px;
    height: 64px;
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    border: 3px solid #e5e7eb;
    border-radius: 0.5rem;
    background: white;
    color: #1a1a1a;
    font-family: 'Courier New', Consolas, monospace;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -moz-appearance: textfield;
}

.fraction-box::-webkit-outer-spin-button,
.fraction-box::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fraction-box:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem var(--focus-shadow);
}

.fraction-box:disabled {
    background: #f8f9fa;
    opacity: 0.7;
    cursor: not-allowed;
}

/* The horizontal fraction bar */
.fraction-bar {
    width: 80px;
    height: 4px;
    background: #1a1a1a;
    border-radius: 2px;
    margin: 6px 0;
}

/* Correct flash state */
.fraction-box.correct-flash {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
    animation: flash-correct 0.6s ease;
}

/* Incorrect flash state */
.fraction-box.incorrect-flash {
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    animation: flash-wrong 0.6s ease;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .fraction-box {
        width: 64px;
        height: 56px;
        font-size: 1.4rem;
    }

    .fraction-bar {
        width: 64px;
    }

    .mixed-number-wrapper {
        gap: 1rem;
    }
}