/**
 * Quiz Game Styles
 * "Which Surah?" - أي سورة؟
 * 
 * Themed to match the app's green/white/gold color scheme
 * with glassmorphism and smooth animations
 */

/* =========================================
   MODAL CONTAINER
   ========================================= */

.quiz-game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quiz-game-modal.active {
    opacity: 1;
}

.quiz-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.quiz-container {
    position: relative;
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--card-bg, #fff);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: quiz-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes quiz-slide-up {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* =========================================
   HEADER
   ========================================= */

.quiz-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quiz-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.quiz-title-icon {
    font-size: 1.5rem;
}

.quiz-title-arabic {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1rem;
    opacity: 0.9;
}

.quiz-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.quiz-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* =========================================
   CONTENT AREA
   ========================================= */

.quiz-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* =========================================
   START SCREEN
   ========================================= */

.quiz-start-screen {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.quiz-intro {
    text-align: center;
}

.quiz-intro-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.quiz-intro-text {
    color: var(--text-color, #333);
    font-size: 1rem;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.quiz-plays-remaining {
    display: inline-block;
    padding: 8px 16px;
    background: var(--highlight-bg, rgba(58, 157, 116, 0.1));
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-color, #3a9d74);
}

.quiz-plays-remaining .plays-count {
    font-weight: 700;
    font-size: 1.1rem;
}

.quiz-plays-remaining.exhausted {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.quiz-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark, #2a7a58);
    margin: 0 0 12px 0;
    text-align: center;
}

.quiz-difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-difficulty-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card-bg, #fff);
    border: 2px solid var(--border-color, #e0e5e8);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quiz-difficulty-btn:hover:not(.disabled) {
    border-color: var(--primary-color, #3a9d74);
    background: var(--highlight-bg, rgba(58, 157, 116, 0.05));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color, rgba(40, 60, 50, 0.1));
}

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

.difficulty-icon {
    font-size: 2rem;
    width: 50px;
    text-align: center;
}

.difficulty-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color, #333);
}

.difficulty-info {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--muted-text, #666);
}

.difficulty-info span {
    background: var(--pending-bg, #f0f0f0);
    padding: 2px 8px;
    border-radius: 10px;
}

.difficulty-desc {
    font-size: 0.85rem;
    color: var(--muted-text, #666);
    margin-top: 2px;
}

.quiz-rules {
    background: var(--highlight-bg, rgba(58, 157, 116, 0.05));
    border-radius: 12px;
    padding: 16px;
}

.quiz-rules h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--primary-dark, #2a7a58);
}

.quiz-rules ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quiz-rules li {
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-color, #333);
}

/* =========================================
   QUESTION SCREEN
   ========================================= */

.quiz-question-screen {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quiz-stats-bar {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.quiz-stat {
    flex: 1;
    text-align: center;
    padding: 8px;
    background: var(--pending-bg, #f0f0f0);
    border-radius: 8px;
}

.quiz-stat .stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--muted-text, #666);
    text-transform: uppercase;
}

.quiz-stat .stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #333);
}

.quiz-streak.on-fire {
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    animation: streak-glow 1s ease-in-out infinite alternate;
}

@keyframes streak-glow {
    from {
        box-shadow: 0 0 5px rgba(252, 211, 77, 0.5);
    }

    to {
        box-shadow: 0 0 15px rgba(252, 211, 77, 0.8);
    }
}

.streak-multiplier {
    display: inline-block;
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
}

.quiz-lives {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 1.5rem;
}

.quiz-heart {
    transition: transform 0.3s ease;
}

.quiz-heart.empty {
    opacity: 0.4;
    transform: scale(0.9);
}

/* Timer */
.quiz-timer-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-timer-bar {
    flex: 1;
    height: 8px;
    background: var(--pending-bg, #e0e0e0);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-timer-fill {
    height: 100%;
    background: var(--primary-color, #3a9d74);
    border-radius: 4px;
    transition: width 1s linear, background 0.3s ease;
}

.quiz-timer-fill.urgent {
    animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.quiz-timer-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color, #3a9d74);
    min-width: 40px;
    text-align: right;
}

/* Ayah Display */
.quiz-ayah-container {
    background: linear-gradient(135deg, var(--highlight-bg, rgba(58, 157, 116, 0.1)), rgba(255, 255, 255, 0.5));
    border: 1px solid var(--border-color, #e0e5e8);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
}

.quiz-ayah-text {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.6rem;
    line-height: 2;
    color: var(--text-color, #333);
    margin-bottom: 12px;
}

.quiz-ayah-meta {
    font-size: 0.85rem;
    color: var(--muted-text, #666);
}

/* Options */
.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.quiz-option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
    background: var(--card-bg, #fff);
    border: 2px solid var(--border-color, #e0e5e8);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.quiz-option-btn:hover:not(:disabled):not(.eliminated) {
    border-color: var(--primary-color, #3a9d74);
    background: var(--highlight-bg, rgba(58, 157, 116, 0.05));
    transform: translateY(-2px);
}

.quiz-option-btn:disabled {
    cursor: not-allowed;
}

.quiz-option-btn.eliminated {
    opacity: 0.3;
    border-color: #ccc;
    background: #f5f5f5;
    text-decoration: line-through;
}

.quiz-option-btn.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    animation: correct-glow 0.5s ease-out;
}

@keyframes correct-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.quiz-option-btn.wrong {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.quiz-option-btn.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-8px);
    }

    40%,
    80% {
        transform: translateX(8px);
    }
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color, #3a9d74);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.option-content {
    flex: 1;
    min-width: 0;
}

.option-arabic {
    display: block;
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.1rem;
    color: var(--text-color, #333);
}

.option-english {
    display: block;
    font-size: 0.8rem;
    color: var(--muted-text, #666);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Hint Button */
.quiz-hint-container {
    text-align: center;
}

.quiz-hint-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    border: none;
    border-radius: 20px;
    color: #7c2d12;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-hint-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

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

.hint-icon {
    font-size: 1.2rem;
}

.hint-count {
    opacity: 0.8;
    font-weight: 400;
}

/* =========================================
   RESULT SCREEN
   ========================================= */

.quiz-result-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 10px 0;
}

.result-feedback {
    animation: result-bounce 0.5s ease;
}

@keyframes result-bounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.result-icon {
    font-size: 4rem;
}

.result-text {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color, #333);
}

.quiz-result-screen.correct .result-text {
    color: #22c55e;
}

.quiz-result-screen.wrong .result-text {
    color: #ef4444;
}

.result-arabic {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.3rem;
    color: var(--muted-text, #666);
}

.result-surah-info {
    background: var(--highlight-bg, rgba(58, 157, 116, 0.1));
    border-radius: 16px;
    padding: 20px;
    width: 100%;
}

.surah-badge {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.surah-arabic {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.8rem;
    color: var(--primary-dark, #2a7a58);
}

.surah-english {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color, #333);
}

.surah-meaning {
    font-size: 0.95rem;
    color: var(--muted-text, #666);
    font-style: italic;
}

.surah-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted-text, #666);
}

.result-points {
    width: 100%;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e0e5e8);
    border-radius: 12px;
    padding: 16px;
}

.points-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.95rem;
    color: var(--text-color, #333);
}

.points-row.bonus {
    color: #22c55e;
}

.points-row.total {
    border-top: 1px solid var(--border-color, #e0e5e8);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.result-lives {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lives-lost {
    font-size: 1.5rem;
    animation: heart-break 0.5s ease;
}

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

    50% {
        transform: scale(1.3) rotate(-10deg);
    }

    100% {
        transform: scale(1);
    }
}

.lives-remaining {
    font-size: 0.9rem;
    color: var(--muted-text, #666);
}

.quiz-next-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(58, 157, 116, 0.4);
}

/* =========================================
   GAME OVER SCREEN
   ========================================= */

.quiz-gameover-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 10px 0;
}

.gameover-header {
    animation: gameover-entrance 0.6s ease;
}

@keyframes gameover-entrance {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.gameover-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-dark, #2a7a58);
}

.gameover-subtitle {
    font-family: var(--arabic-font, 'Amiri', serif);
    font-size: 1.2rem;
    color: var(--muted-text, #666);
}

.gameover-score {
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
    padding: 24px 40px;
    border-radius: 16px;
    animation: score-pop 0.5s ease 0.2s both;
}

@keyframes score-pop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.score-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1.2;
}

.score-stars {
    font-size: 1.5rem;
    margin-top: 8px;
}

.gameover-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--pending-bg, #f0f0f0);
    border-radius: 12px;
}

.stat-item .stat-icon {
    font-size: 1.3rem;
}

.stat-item .stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-color, #333);
}

.stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--muted-text, #666);
    text-transform: uppercase;
}

.gameover-perfect {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #fef3c7, #fcd34d);
    border-radius: 12px;
    animation: perfect-shine 2s ease-in-out infinite;
}

@keyframes perfect-shine {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(252, 211, 77, 0.5);
    }

    50% {
        box-shadow: 0 0 25px rgba(252, 211, 77, 0.8);
    }
}

.perfect-icon {
    font-size: 2rem;
}

.perfect-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: #92400e;
}

.perfect-bonus {
    font-size: 0.9rem;
    color: #b45309;
}

.gameover-grade {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
}

.grade-label {
    color: var(--muted-text, #666);
}

.grade-value {
    font-size: 1.8rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 8px;
}

.grade-Aplus {
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    color: #7c2d12;
}

.grade-A {
    background: #22c55e;
    color: white;
}

.grade-B {
    background: #3b82f6;
    color: white;
}

.grade-C {
    background: #8b5cf6;
    color: white;
}

.grade-D {
    background: #64748b;
    color: white;
}

.gameover-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.quiz-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-action-btn.primary {
    background: linear-gradient(135deg, var(--primary-color, #3a9d74), var(--primary-dark, #2a7a58));
    color: white;
}

.quiz-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(58, 157, 116, 0.4);
}

.quiz-action-btn.secondary {
    background: var(--pending-bg, #f0f0f0);
    color: var(--text-color, #333);
}

.quiz-action-btn.secondary:hover {
    background: var(--border-color, #e0e5e8);
}

.gameover-plays {
    font-size: 0.85rem;
    color: var(--muted-text, #666);
}

/* =========================================
   LOADING & ERROR STATES
   ========================================= */

.quiz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.quiz-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color, #e0e5e8);
    border-top-color: var(--primary-color, #3a9d74);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.quiz-loading p {
    color: var(--muted-text, #666);
    font-size: 1rem;
}

.quiz-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    text-align: center;
}

.error-icon {
    font-size: 3rem;
}

.error-text {
    color: var(--text-color, #333);
    font-size: 1rem;
}

/* =========================================
   EFFECTS
   ========================================= */

.quiz-points-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    padding: 20px 30px;
    border-radius: 16px;
    text-align: center;
    z-index: 100;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.quiz-points-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.points-main {
    font-size: 2.5rem;
    font-weight: 700;
}

.points-breakdown {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.points-breakdown .bonus {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.quiz-confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confetti-fall 1s ease-out forwards;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) translateX(var(--x, 0)) rotate(var(--r, 360deg));
        opacity: 0;
    }
}

#quiz-score.score-pop {
    animation: score-bump 0.3s ease;
}

@keyframes score-bump {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        color: #22c55e;
    }

    100% {
        transform: scale(1);
    }
}

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 500px) {
    .quiz-container {
        max-height: 95vh;
        border-radius: 16px;
    }

    .quiz-content {
        padding: 16px;
    }

    .quiz-difficulty-options {
        gap: 10px;
    }

    .quiz-difficulty-btn {
        padding: 12px;
    }

    .difficulty-icon {
        font-size: 1.5rem;
        width: 40px;
    }

    .quiz-options {
        grid-template-columns: 1fr;
    }

    .quiz-ayah-text {
        font-size: 1.4rem;
    }

    .gameover-stats {
        grid-template-columns: repeat(2, 1fr);
    }

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

/* =========================================
   DARK MODE
   ========================================= */

body.dark-mode .quiz-container {
    background: var(--card-bg-dark, #252a28);
}

body.dark-mode .quiz-difficulty-btn,
body.dark-mode .quiz-option-btn {
    background: var(--bg-color-dark, #1a1d1c);
    border-color: var(--border-color-dark, #353d3a);
}

body.dark-mode .quiz-stat,
body.dark-mode .stat-item,
body.dark-mode .quiz-action-btn.secondary {
    background: var(--bg-color-dark, #1a1d1c);
}

body.dark-mode .result-points {
    background: var(--bg-color-dark, #1a1d1c);
}