@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

/* ==============================================
   1. ROOT VARIABLES (SISTEM TEMA DINAMIS)
============================================== */
:root {
    /* Warna yang BISA BERUBAH (Default: Chess.com Green) */
    --chess-green: #769656; 
    
    /* Warna PUTIH & NETRAL yang TETAP (Statis) */
    --chess-white: #ffffff;
    --surface-color: #f3f4f6;
    --border-color: #e5e7eb;
    
    /* Warna Teks */
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    
    /* Ukuran Layout */
    --nav-height: 65px;
}

/* ==============================================
   2. RESET & BASE
============================================== */
* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Hilangkan kedip biru di HP */
}

body {
    background-color: var(--surface-color);
    color: var(--text-dark);
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Mencegah scroll bodi, yang scroll hanya kontainer */
}

/* Kontainer Utama memalsukan aplikasi mobile */
#app-container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--chess-white);
    position: relative;
}

/* ==============================================
   3. HEADER ATAS
============================================== */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--chess-white);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.user-snippet {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar-box {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    background-color: var(--surface-color);
    border: 2px solid var(--chess-green);
    overflow: hidden;
}

.avatar-box img { width: 100%; height: 100%; object-fit: cover; }

.user-info { display: flex; flex-direction: column; }
.username { font-weight: 900; font-size: 1rem; color: var(--text-dark); }
.user-elo { font-size: 0.8rem; font-weight: 700; color: var(--chess-green); }

.header-actions { display: flex; gap: 15px; }

.icon-btn {
    background: none; border: none;
    font-size: 1.3rem; color: var(--text-muted);
    position: relative; cursor: pointer; transition: color 0.2s;
}
.icon-btn:hover { color: var(--chess-green); }

.badge {
    position: absolute; top: -5px; right: -8px;
    background-color: #EF4444; color: white;
    font-size: 0.6rem; font-weight: bold;
    padding: 2px 5px; border-radius: 10px; border: 2px solid var(--chess-white);
}

/* ==============================================
   4. KONTEN UTAMA
============================================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 20px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Kartu Mode Main */
.play-card {
    background-color: var(--chess-white);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.play-card:active { transform: scale(0.97); }

/* Khusus Ranked - Menonjol */
.ranked-card {
    background: var(--chess-green);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 120px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.ranked-card .bg-icon {
    position: absolute;
    right: -20px; bottom: -20px;
    font-size: 8rem; opacity: 0.1; color: white;
}

.play-content h2 { font-size: 1.8rem; font-weight: 900; letter-spacing: 1px; }
.play-content p { font-size: 0.85rem; opacity: 0.9; }
.play-icon { font-size: 2rem; background: rgba(255,255,255,0.2); padding: 15px; border-radius: 50%; }

/* Mode Classic & Offline (Grid) */
.secondary-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.small-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100px;
    color: var(--text-dark);
}
.small-card i { font-size: 2rem; color: var(--chess-green); }
.small-card span { font-weight: 900; font-size: 0.9rem; letter-spacing: 0.5px; }

/* Menu Tambahan Cepat (Ikon Melingkar) */
.quick-actions {
    display: flex;
    justify-content: space-around;
    padding: 15px 0;
    margin-top: 10px;
    background: var(--surface-color);
    border-radius: 20px;
}

.quick-btn {
    background: var(--chess-white);
    border: 1px solid var(--border-color);
    width: 50px; height: 50px;
    border-radius: 50%;
    font-size: 1.2rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.quick-btn:active { background: var(--chess-green); color: white; transform: scale(0.9); }

/* ==============================================
   5. BOTTOM NAVIGATION BAR
============================================== */
.bottom-nav {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    height: var(--nav-height);
    background-color: var(--chess-white);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-item {
    background: none; border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.3s;
    position: relative;
}

/* State Aktif Navigasi */
.nav-item.active { color: var(--chess-green); transform: translateY(-5px); }
.nav-item.active::after {
    content: ''; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
    width: 5px; height: 5px; background: var(--chess-green); border-radius: 50%;
}

/* ==============================================
   6. SISTEM MODAL / POPUP
============================================== */
#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(3px);
    z-index: 200;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
#modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-box {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -40%);
    width: 90%; max-width: 400px;
    background: var(--chess-white);
    border-radius: 20px;
    z-index: 201;
    opacity: 0; pointer-events: none; transition: all 0.3s ease;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
    max-height: 80vh; overflow: hidden;
}
.modal-box.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid var(--border-color);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 900; color: var(--text-dark); display: flex; gap: 10px; align-items: center;}
.close-btn { background: var(--surface-color); border: none; width: 30px; height: 30px; border-radius: 50%; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.text-center { text-align: center; }

/* Komponen dalam Modal */
.modal-tabs { display: flex; background: var(--surface-color); padding: 5px; margin: 15px 15px 0 15px; border-radius: 10px; }
.tab { flex: 1; background: transparent; border: none; padding: 8px; border-radius: 8px; font-weight: bold; color: var(--text-muted); cursor: pointer;}
.tab.active { background: var(--chess-white); color: var(--chess-green); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

.list-item { padding: 15px; border-bottom: 1px solid var(--border-color); font-weight: bold; display: flex; gap: 15px; align-items: center; color: var(--text-dark);}
.list-item i { color: var(--chess-green); font-size: 1.2rem; }

.btn-primary {
    background: var(--chess-green); color: white; border: none;
    padding: 15px; border-radius: 12px; font-weight: 900; font-size: 1rem;
    cursor: pointer; transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.8; }

/* =========================================
   DESAIN GRID TEMA WARNA
========================================= */
.theme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 10px 0;
}

.theme-color {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.theme-color:active {
    transform: scale(0.85); /* Efek mengecil saat ditekan */
}

/* ==============================================
   DESAIN KHUSUS MODAL PENGATURAN
============================================== */
.settings-scroll {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.settings-section h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.settings-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 5px 0;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: var(--surface-color);
    padding: 12px 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.setting-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-dark);
}

.setting-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Kustomisasi Dropdown (Select) */
.setting-select {
    background: var(--chess-white);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 800;
    outline: none;
    cursor: pointer;
}

/* Toggle Switch Keren ala Mobile Modern */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s ease;
    border-radius: 30px;
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .slider {
    background-color: var(--chess-green);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Tombol Pengaturan Akun */
.setting-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    transition: background 0.2s, transform 0.1s;
}

.setting-btn:active {
    transform: scale(0.98);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
}

.btn-outline:active {
    background: var(--surface-color);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid #EF4444;
    color: #EF4444;
}

.btn-danger-outline:active {
    background: #FEF2F2;
}

.btn-danger {
    background: #EF4444;
    border: none;
    color: white;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}

/* ==============================================
   7. CHAT GLOBAL EDGE PANEL (LIDI KIRI)
============================================== */
#edge-chat-trigger {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 6px; /* Sangat tipis seperti lidi */
    height: 80px;
    background-color: var(--chess-green);
    border-radius: 0 10px 10px 0;
    z-index: 999;
    cursor: pointer;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    transition: width 0.2s, background-color 0.2s;
}

#edge-chat-trigger:active {
    width: 12px;
    background-color: #3B82F6;
}

#edge-chat-panel {
    position: fixed;
    top: 0;
    left: -100%; /* Sembunyi di luar layar kiri */
    width: 85%;
    max-width: 350px;
    height: 100vh;
    background: var(--chess-white);
    z-index: 1001;
    transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 5px 0 25px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

#edge-chat-panel.open {
    left: 0; /* Muncul ke layar */
}

#chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.chat-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid var(--border-color);
}

/* ==============================================
   8. PEROMBAKAN TOMBOL MODEREN & DINAMIS
============================================== */
.dynamic-modes {
    display: flex;
    gap: 15px;
    justify-content: space-between;
}

.modern-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    min-height: 140px;
    border-radius: 20px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.3s;
    border: none; /* Hilangkan batas kaku sebelumnya */
}

.modern-card:active { transform: scale(0.97); }

/* Tombol Classic - Poligon Hijau-Emas */
.classic-modern {
    background: linear-gradient(135deg, #769656, #C5A059);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.classic-modern::before {
    content: ''; position: absolute; top: -20px; right: -20px;
    width: 100px; height: 100px;
    background: url('https://www.transparenttextures.com/patterns/fabric-of-the-nation.png');
    opacity: 0.15;
}

.classic-modern .card-icon-box i { color: #FFF8E1; filter: drop-shadow(0 0 5px rgba(255, 248, 225, 0.5)); }
.classic-modern h3 { color: #FFF8E1; text-shadow: 1px 1px 2px rgba(0,0,0,0.2); }

/* Tombol Offline - Poligon Biru-Perak */
.offline-modern {
    background: linear-gradient(135deg, #1A497A, #A6ACAF);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.offline-modern::before {
    content: ''; position: absolute; top: -20px; right: -20px;
    width: 100px; height: 100px;
    background: url('https://www.transparenttextures.com/patterns/micro-circuits.png');
    opacity: 0.15;
}

.offline-modern .card-icon-box i { color: #E3F2FD; filter: drop-shadow(0 0 5px rgba(227, 242, 253, 0.5)); }
.offline-modern h3 { color: #E3F2FD; text-shadow: 1px 1px 2px rgba(0,0,0,0.2); }

/* Detail Ikon & Teks */
.card-icon-box {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}

.card-icon-box i { font-size: 2.2rem; }
.card-content h3 { font-size: 1rem; font-weight: 900; letter-spacing: 0.5px; }

/* Menimpa gaya .play-card lama di kontainer ini agar Ranked Card tidak ikut rusak */
.dynamic-modes .play-card {
    height: auto;
}

/* ==============================================
   9. EFEK IKON BACKGROUND RAKSASA & ASIMETRI
============================================== */
/* Modifikasi penempatan dasar konten di dalam kartu */
.modern-card {
    justify-content: flex-end !important; /* Teks di posisi bawah */
    padding: 20px 15px !important;
}

/* Teks yang ada di atas ikon background (JANGAN DIHAPUS) */
.card-content-alt {
    position: relative;
    z-index: 10;
}

.card-content-alt h3 {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin: 0;
}

/* Dasar Ikon Raksasa (Posisi akan diatur asimetris di bawah) */
.bg-icon-small {
    position: absolute;
    font-size: 6.5rem; /* Ukuran besar */
    opacity: 0.15; /* Transparan */
    color: white;
    z-index: 1;
    transition: transform 0.3s ease;
}

/* Animasi tambahan saat tombol ditekan (JANGAN DIHAPUS) */
.modern-card:active .bg-icon-small {
    transform: scale(1.1);
}

/* -------------------------------------------
   EFEK ASIMETRI (POSISI BERBEDA BIAR KEREN)
------------------------------------------- */

/* Kartu Classic: Teks di Kiri Bawah, Ikon di Kanan Atas */
.classic-modern {
    align-items: flex-start !important; 
}
.classic-modern .bg-icon-small {
    top: -15px;
    right: -15px;
}

/* Kartu Offline: Teks di Kanan Bawah, Ikon di Kiri Bawah */
.offline-modern {
    align-items: flex-end !important; 
}
.offline-modern .bg-icon-small {
    bottom: -20px;
    left: -15px;
}

/* ==============================================
   10. PEROMBAKAN KARTU RANKED (ELO & ANIMASI)
============================================== */
/* Tata letak lencana Rank dan Elo */
.rank-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

/* Lencana Teks (Grandmaster, Master, dll) */
.rank-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(2px); /* Efek kaca kekinian */
}

/* Warna Emas Pucat untuk Elo agar nyaman di mata (tidak menyilaukan) */
.elo-score {
    font-size: 0.9rem;
    font-weight: 800;
    color: #FDE68A; 
    display: flex;
    align-items: center;
    gap: 5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* -------------------------------------------
   ANIMASI BIDAK & TOMBOL PLAY
------------------------------------------- */
/* Animasi Kuda Melayang Halus (Durasi 4 detik agar tidak pusing dilihat lama) */
.animated-knight {
    animation: floatKnight 4s ease-in-out infinite;
}

@keyframes floatKnight {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(-5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* Tombol Play Baru dengan Efek Denyut (Pulse) Lembut */
.play-btn-pulse {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4);
    animation: pulsePlay 2s infinite;
    z-index: 10;
}

@keyframes pulsePlay {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* --- DESAIN EVENT BARU --- */
.event-entry-widget {
    background: var(--chess-white);
    border: 1px solid var(--border-color);
    padding: 15px;
    display: flex;
    align-items: center;
    border-radius: 18px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
    cursor: pointer;
}
.widget-accent-bar {
    width: 4px;
    height: 60%;
    background: var(--chess-green);
    border-radius: 10px;
    position: absolute;
    left: 0;
}
.sticky-ap-dashboard {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}
.premium-ticket-box {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: white; 
    padding: 25px; 
    border-radius: 20px;
    text-align: center; 
    margin-bottom: 20px;
}
.mission-card {
    background: var(--chess-white);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
}

/* ==============================================
   EFEK AMBIENT BACKGROUND (RANDOM SHIFT)
============================================== */
#app-container {
    /* Membuat gradasi warna dari putih murni ke abu-abu mutiara */
    background: linear-gradient(
        45deg, 
        #ffffff, 
        #f8fafc, 
        #e2e8f0, 
        #ffffff
    ) !important;
    
    /* Perbesar ukuran background menjadi 400% agar bisa digeser */
    background-size: 400% 400% !important;
    
    /* Transisi pergeseran sangat pelan dan halus (12 detik) */
    transition: background-position 12s ease-in-out !important;
}

/* Header atas tetap transparan bersih */
.top-header {
    background: transparent !important;
}

/* Navigasi bawah menggunakan efek Kaca Embun (Glassmorphism) */
.bottom-nav {
    background: rgba(255, 255, 255, 0.1) !important; /* Transparan sangat tipis */
    backdrop-filter: blur(12px); /* Efek blur/kaca embun untuk objek di belakangnya */
    -webkit-backdrop-filter: blur(12px); /* Dukungan untuk browser Safari/iPhone */
    border-top: 1px solid rgba(255, 255, 255, 0.3) !important; /* Garis batas tipis bercahaya */
}

/* Konten utama tetap transparan */
.main-content {
    background: transparent !important;
}