/* Base Styles */
:root {
    --primary-color: rgb(253, 198, 16);
    --secondary-color: rgb(218, 191, 35);
    --accent-color: #FFD700;
    --danger-color: #f5576c;
    --success-color: #4CAF50;
    --text-color: rgb(255, 255, 255);
    --light-color: #F7FAFC;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-repeat: no-repeat;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    /* Background image dihandle via inline style/internal css di masing-masing page */
    transition: background-image 0.5s ease-in-out;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Mobile First Approach */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    h2 {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }
    
    h2 {
        font-size: 1.2em;
    }
}

/* =========================================
   LOADING SCREEN STYLES (BARU)
   ========================================= */

/* Overlay Loading */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999; /* Paling depan */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

/* Animasi Spinner */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
    box-shadow: 0 0 15px rgba(253, 198, 16, 0.5);
}

/* Teks Loading */
.loading-text {
    color: white;
    font-weight: 800;
    font-size: 1.2em;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    animation: pulse 1.5s infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Class untuk menyembunyikan loader */
.loader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Leaderboard Styles */
.leaderboard-container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 15px;
    padding: 20px;
}

.lb-header {
    display: flex;
    padding: 15px 20px;
    color: #a0aec0;
    font-weight: bold;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.lb-item {
    display: flex;
    align-items: center;
    background: white;
    margin-bottom: 10px;
    padding: 15px 20px;
    border-radius: 12px;
    transition: transform 0.2s;
    color: #2d3748;
}

.lb-item:hover {
    transform: scale(1.02);
}

.lb-rank {
    flex: 0.5;
    font-size: 1.5em;
    font-weight: bold;
    color: #718096;
}

.lb-info {
    flex: 2;
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.lb-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: contain;
    background: #edf2f7;
    border: 2px solid #e2e8f0;
}

.lb-name {
    font-weight: bold;
    font-size: 1.1em;
}

.lb-coins {
    flex: 1;
    text-align: right;
    font-weight: bold;
    color: #d69e2e;
    font-size: 1.1em;
}

/* Juara 1 (Emas) */
.lb-item.rank-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FDB931 100%);
    border: 2px solid #fff;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    color: #744210;
}
.lb-item.rank-1 .lb-rank { color: #744210; }
.lb-item.rank-1 .lb-coins { color: #744210; }

/* Juara 2 (Perak) */
.lb-item.rank-2 {
    background: linear-gradient(135deg, #E0E0E0 0%, #BDBDBD 100%);
    color: #424242;
}
.lb-item.rank-2 .lb-rank { color: #424242; }
.lb-item.rank-2 .lb-coins { color: #424242; }

/* Juara 3 (Perunggu) */
.lb-item.rank-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #A0522D 100%);
    color: #fff;
}
.lb-item.rank-3 .lb-rank { color: #fff; }
.lb-item.rank-3 .lb-coins { color: #fff; }

/* Cegah seleksi teks saat spam klik */
.game-container, .click-area, .cat-image, .click-button {
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10 and IE 11 */
    user-select: none; /* Standard syntax */
    -webkit-touch-callout: none; /* iOS Safari */
}

/* Optimasi kursor */
.click-area {
    cursor: pointer;
    touch-action: manipulation; /* Mempercepat respons tap di mobile */
}

/* --- CSS POPUP WELCOME (Floating Style) --- */

/* Menghapus background putih kotak default */
div:where(.swal2-container) div:where(.swal2-popup).custom-welcome-popup {
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important; /* Supaya tombol close (X) di luar area bisa terlihat jika mau */
}

/* Mengatur gambar agar responsif */
div:where(.swal2-container) .swal2-image {
    margin: 0 !important;
    border-radius: 15px; /* Sudut gambar membulat */
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); /* Bayangan di belakang gambar */
    border: 3px solid var(--primary-color); /* List warna emas/kuning tema game */
    object-fit: cover;
}

/* Tombol Tutup Custom di Bawah */
.popup-close-btn {
    background: var(--danger-color); /* Merah */
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1em;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: 0 4px 0 #c0392b; /* Efek 3D */
    transition: transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.popup-close-btn:hover {
    transform: translateY(-2px);
    background: #ff6b81;
}

.popup-close-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #c0392b;
}

/* Tombol Silang (X) bawaan (Opsional: disembunyikan atau dipercantik) */
div:where(.swal2-container) .swal2-close {
    background: white;
    color: black;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    position: absolute;
    top: -10px;
    right: -10px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* --- NEW MISSION STYLES --- */

.mission-header {
    background: linear-gradient(135deg, #f9af3a 0%, #a24b4b 100%);
    padding: 20px;
    border-radius: 12px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
}

.mission-timer {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.2em;
    background: rgba(0,0,0,0.3);
    padding: 5px 15px;
    border-radius: 20px;
}

.mission-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.mission-card {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 5px solid #e2e8f0;
    position: relative;
    overflow: hidden;
}

.mission-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.mission-card.completed {
    border-left-color: var(--success-color);
    background: #f0fff4;
}

.mission-card.claimed {
    border-left-color: #cbd5e0;
    opacity: 0.7;
    filter: grayscale(0.8);
}

.mission-icon {
    font-size: 1.8em;
    color: var(--primary-color);
    background: #fff9c4;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.mission-details {
    flex: 1;
}

.mission-title {
    font-weight: 800;
    color: #2d3748;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.mission-desc {
    font-size: 0.85em;
    color: #718096;
    margin-bottom: 8px;
}

.mission-bar-bg {
    background: #edf2f7;
    height: 8px;
    border-radius: 4px;
    width: 100%;
    overflow: hidden;
}

.mission-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #FDB931 0%, #FFD700 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.mission-action {
    text-align: right;
    min-width: 80px;
}

.mission-reward {
    font-size: 0.9em;
    font-weight: bold;
    color: #d69e2e;
    margin-bottom: 5px;
    display: block;
}

/* Button override */
.btn-claim {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(72, 187, 120, 0.3);
    animation: pulse 2s infinite;
}

.btn-progress {
    background: #e2e8f0;
    color: #718096;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: default;
}

/* CSS untuk Sub-Menu Shop */
.shop-nav-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 12px;
}

.shop-tab-btn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.1);
    color: #aaa;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shop-tab-btn:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.shop-tab-btn.active {
    background: var(--primary-color);
    color: rgb(56, 42, 0); /* Warna teks gelap biar kontras */
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(253, 198, 16, 0.3);
}

.shop-section {
    animation: fadeIn 0.4s ease-in-out;
}