/* =====================
   POPUPS (Summary, Detail, Hint)
   ===================== */

/* Hint popup styles */
.hint-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    z-index: 5000;
    max-width: 400px;
    width: 90%;
    display: none;
}

.hint-popup.active {
    display: block;
    animation: popIn 0.3s ease;
}

.hint-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.hint-popup-content {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.hint-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.hint-popup-close:hover {
    color: var(--text-primary);
}

.hint-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 4999;
    display: none;
}

.hint-overlay.active {
    display: block;
}

/* Summary Popup Styles */
.summary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.summary-overlay.active {
    display: flex !important;
}

.summary-overlay.active .summary-popup {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.summary-popup {
    background: #FFFFFF !important;
    border-radius: 20px;
    padding: 0;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    visibility: hidden;
    opacity: 0;
}

/* Popup header stays fixed at top */
.summary-popup-header {
    flex-shrink: 0;
    z-index: 2;
}

.summary-popup-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
    padding: 20px;
    min-height: 0;
    max-height: calc(85vh - 120px);
    background: white;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #2D3436 !important;
}

.summary-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f1f2f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    color: #636e72;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-popup-close:hover {
    background: var(--danger);
    color: white;
}

.summary-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 25px 15px 25px;
    border-bottom: 3px solid var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* ================= CHILD-FRIENDLY SUMMARY STYLES ================= */

.summary-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Winner Celebration */
.winner-celebration {
    display: flex;
    align-items: center;
    gap: 15px;
    background: linear-gradient(135deg, #FFF9E6, #FFFDE7);
    padding: 15px 20px;
    border-radius: 16px;
    border: 3px solid #FFD700;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.winner-avatar {
    font-size: 3rem;
    background: white;
    padding: 10px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.winner-info {
    flex: 1;
}

.winner-label {
    font-size: 0.75rem;
    color: #B8860B;
    font-weight: 700;
    letter-spacing: 1px;
}

.winner-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2D3436;
    margin: 4px 0;
}

.winner-score {
    font-size: 1rem;
    color: #636E72;
    font-weight: 600;
}

/* Quick Stats Row */
.quick-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.quick-stat-card {
    background: white;
    padding: 12px 8px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid #f0f0f0;
    transition: transform 0.2s;
}

.quick-stat-card:hover {
    transform: translateY(-2px);
}

.quick-stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.quick-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.quick-stat-label {
    font-size: 0.7rem;
    color: #636E72;
    font-weight: 600;
}

/* Summary Sections */
.summary-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 16px;
}

.summary-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

.summary-section-title.warning {
    color: #E17055;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px 12px;
    border-radius: 10px;
    border-left: 4px solid;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.category-icon {
    font-size: 1.3rem;
}

.category-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.85rem;
    color: #2D3436;
}

.category-count {
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Player Performance List */
.player-performance-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 250px;
    min-height: 80px;
    flex-shrink: 0;
}

.player-card {
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.player-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.player-card-avatar {
    font-size: 1.8rem;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 10px;
}

.player-card-info {
    flex: 1;
}

.player-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2D3436;
}

.player-card-stats {
    font-size: 0.75rem;
    color: #636E72;
}

.accuracy-badge {
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 700;
}

.player-card-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.detail-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 600;
}

.detail-badge.good {
    background: #E8F5E9;
    color: #2E7D32;
}

.detail-badge.needs {
    background: #FFF3E0;
    color: #E65100;
}

/* Questions Review List */
.questions-review-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.question-review-card {
    background: white;
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 2px solid #FFEBEE;
}

.question-review-card.status-correct {
    border-left: 4px solid #00c853;
}

.question-review-card.status-wrong {
    border-left: 4px solid #ff6b6b;
}

.question-review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.question-category-tag {
    background: var(--primary);
    color: white;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
}

.question-category-full {
    background: var(--bg-secondary);
    color: var(--text);
    padding: 4px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.question-number {
    font-size: 0.85rem;
    color: #B2BEC3;
    font-weight: 700;
}

.question-status {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.question-status.status-correct {
    background: #E8F5E9;
    color: #00c853;
}

.question-status.status-wrong {
    background: #FFEBEE;
    color: #ff6b6b;
}

.question-review-text {
    font-size: 0.95rem;
    color: #2D3436;
    margin-bottom: 10px;
    font-weight: 500;
    line-height: 1.5;
}

.question-review-answer {
    background: #E8F5E9;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
}

.question-review-card.status-wrong .question-review-answer {
    background: #FFEBEE;
}

.answer-label {
    font-size: 0.75rem;
    color: #2E7D32;
    font-weight: 600;
    margin-right: 6px;
}

.question-review-card.status-wrong .answer-label {
    color: #c62828;
}

.answer-text {
    font-size: 0.85rem;
    color: #2D3436;
    font-weight: 600;
}

.question-review-who {
    display: flex;
    gap: 15px;
    font-size: 0.75rem;
    font-weight: 600;
}

.correct-text {
    color: #00c853;
}

.wrong-text {
    color: #ff6b6b;
}

.question-review-who .correct-text:empty::before {
    content: 'Benar: -';
    color: #B2BEC3;
}

.question-review-who .wrong-text:empty::before {
    content: 'Salah: -';
    color: #B2BEC3;
}

/* Summary Popup Action Buttons */
.summary-popup-actions {
    display: flex;
    gap: 12px;
    padding: 15px 20px;
    border-top: 2px solid var(--bg-secondary);
    background: #f8f9fa;
    border-radius: 0 0 20px 20px;
    flex-shrink: 0;
}

.summary-action-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.summary-action-btn.primary {
    background: linear-gradient(135deg, #00c853, #00e676);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 200, 83, 0.3);
}

.summary-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 200, 83, 0.4);
}

.summary-action-btn.secondary {
    background: white;
    color: #636e72;
    border: 2px solid #dfe6e9;
}

.summary-action-btn.secondary:hover {
    background: #f1f2f6;
    border-color: #b2bec3;
}

.summary-action-btn i {
    font-size: 1rem;
}

/* ================= GAME HISTORY & DETAIL POPUP STYLES ================= */

/* Detail Popup */
.detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.detail-overlay.active {
    display: flex !important;
}

.detail-overlay.active .detail-popup {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.detail-popup {
    background: #FFFFFF !important;
    border-radius: 20px;
    padding: 0;
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    visibility: hidden;
    opacity: 0;
}

.detail-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #f1f2f6;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    color: #636e72;
    transition: all 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-popup-close:hover {
    background: var(--danger);
    color: white;
}

.detail-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 25px 15px 25px;
    border-bottom: 3px solid var(--primary);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.detail-popup-content {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    display: block;
    padding: 20px;
    min-height: 300px;
    max-height: 60vh;
    background: white !important;
    color: #2D3436 !important;
    -webkit-overflow-scrolling: touch;
}

.detail-popup-content * {
    background: transparent !important;
    color: #2D3436 !important;
}

/* Export Controls Styles */
.export-controls {
    display: flex;
    gap: 8px;
    margin: 15px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.export-btn {
    padding: 8px 16px;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.export-btn:active {
    transform: translateY(0);
}

.export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Game Detail Container */
.game-detail-container {
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 20px;
    color: #2D3436 !important;
    overflow-y: auto;
    flex-shrink: 0;
}

.game-detail-container * {
    color: #2D3436 !important;
}

.game-detail-container h4 {
    color: #6C5CE7 !important;
}

.game-detail-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.game-detail-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #6C5CE7 !important;
    margin-bottom: 5px;
}

.game-detail-date {
    color: #636E72 !important;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.game-detail-meta {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 0.85rem;
    color: #636E72 !important;
}

.game-detail-section {
    margin-bottom: 25px;
}

.game-detail-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6C5CE7 !important;
    font-size: 1.1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

/* Final Scores */
.game-final-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-score-row {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #636E72;
}

.game-score-row.gold {
    background: linear-gradient(135deg, #FFF9E6, #FFF3CD);
    border-left-color: #FFD700;
}

.game-score-row.silver {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-left-color: #C0C0C0;
}

.game-score-row.bronze {
    background: linear-gradient(135deg, #FFF5F0, #FFE8DC);
    border-left-color: #CD7F32;
}

.game-rank {
    font-size: 1.2rem;
    margin-right: 12px;
    width: 30px;
}

.game-player-name {
    flex: 1;
    font-weight: 700;
    font-size: 1rem;
    color: #2D3436 !important;
}

.game-player-score {
    font-weight: 700;
    color: #6C5CE7 !important;
    font-size: 1.1rem;
}

/* Category Grid */
.game-category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.game-cat-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
}

.game-cat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.game-cat-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #2D3436 !important;
}

.game-cat-count {
    font-size: 0.85rem;
    color: #636E72 !important;
}

.game-cat-bar {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.game-cat-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Player Detail */
.game-player-detail {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
}

.game-player-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e9ecef;
}

.game-player-avatar {
    font-size: 1.5rem;
}

.game-player-name {
    font-weight: 700;
    font-size: 1rem;
    color: #2D3436 !important;
}

.game-player-cat-row {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.game-player-cat-row:last-child {
    border-bottom: none;
}

.game-cat-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #636E72 !important;
}

.game-cat-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-cat-progress-bar {
    flex: 1;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.game-cat-progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.game-cat-accuracy {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 45px;
    text-align: right;
}

.game-cat-stats {
    font-size: 0.75rem;
    color: #636E72 !important;
    text-align: right;
}

/* Questions Log */
.game-questions-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.game-question-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px;
    border-left: 4px solid #636E72;
}

.game-question-item.correct {
    background: #f0fff4;
    border-left-color: #00B894;
}

.game-question-item.wrong {
    background: #fff5f5;
    border-left-color: #FF7675;
}

.game-question-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.game-q-number {
    font-weight: 700;
    font-size: 0.8rem;
    color: #636E72 !important;
}

.game-q-category {
    background: #6C5CE7;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.game-q-result {
    margin-left: auto;
    font-weight: 700;
    font-size: 0.85rem;
}

.game-question-text {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 8px;
    color: #2D3436 !important;
}

.game-question-answer {
    font-size: 0.85rem;
    color: #00B894 !important;
    font-weight: 600;
    margin-bottom: 8px;
}

.game-question-players {
    display: flex;
    gap: 15px;
    font-size: 0.75rem;
}

.game-correct-players {
    color: #00B894 !important;
}

.game-wrong-players {
    color: #FF7675 !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .game-category-grid {
        grid-template-columns: 1fr;
    }
    
    .game-player-cat-row {
        grid-template-columns: 70px 1fr 70px;
        font-size: 0.85rem;
    }
    
    .game-detail-meta {
        flex-direction: column;
        gap: 5px;
    }
}
