:root {
    --bg-color: #000000;
    --surface-color: #1C1C1E; 
    --surface-light: #2C2C2E;
    --primary-color: #BF5AF2; 
    --primary-hover: #D8B4FE;
    --text-main: #FFFFFF;
    --text-muted: #EBEBF599;
    --danger: #FF453A;
    --radius-lg: 24px;
    --radius-md: 14px;
}

/* RESET & SAFARI FIXES */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
input, button { -webkit-appearance: none; appearance: none; outline: none; }

/* FIX SCROLLING MUTLAK UNTUK SEMUA BROWSER */
body, html { 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    width: 100%; 
    min-height: 100%; 
}

#app { 
    width: 100%; 
    max-width: 430px; 
    min-height: 100dvh;
    margin: 0 auto;
    position: relative; 
    background-color: var(--bg-color); 
    display: flex; 
    flex-direction: column; 
}

/* --- TRANSISI & LAYAR --- */
.screen { 
    padding: 30px 24px; 
    padding-bottom: max(30px, env(safe-area-inset-bottom)); 
    display: none; 
    animation: fadeScale 0.3s ease-out; 
    flex: 1 1 0; 
    min-height: 0; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    flex-direction: column; 
}
.screen.active { display: flex; }
@keyframes fadeScale { from { opacity: 0; transform: scale(0.97) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.hidden { display: none !important; }

/* --- TYPOGRAPHY & CARDS --- */
.game-title { font-size: 2.5rem; font-weight: 800; text-align: center; margin-top: 5vh; margin-bottom: 30px; letter-spacing: -1px; flex-shrink: 0;}
.game-title span { color: var(--primary-color); font-size: 1.2rem; display: block; letter-spacing: 2px; }
h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 5px; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; }
.text-center { text-align: center; }
.highlight-text { color: var(--primary-color); font-weight: bold; }
.ios-card { background: var(--surface-color); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.05); flex-shrink: 0;}

/* --- BUTTONS & INPUTS --- */
.btn-ios { width: 100%; padding: 16px; border-radius: var(--radius-md); border: none; font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; display: flex; justify-content: center; align-items: center; gap: 12px; flex-shrink: 0;}
.btn-ios:active { transform: scale(0.96); }
.btn-primary { background-color: var(--primary-color); color: #fff; }
.btn-secondary { background-color: var(--surface-light); color: var(--text-main); }
.btn-danger { background-color: rgba(255, 69, 58, 0.15); color: var(--danger); }
.btn-success { background-color: rgba(50, 215, 75, 0.15); color: #32D74B; }
.btn-google { background-color: #ffffff; color: #000000; }
.btn-icon { background: var(--surface-color); border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.2rem; color: white; cursor: pointer; flex-shrink: 0; display: flex; justify-content: center; align-items: center;}

/* TOMBOL KECIL DI SAMPING NAMA (VOTE / KICK / SKILL) */
.btn-action {
    width: auto;
    padding: 8px 14px;
    border-radius: 12px;
    border: none;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s ease;
    color: #fff;
}
.btn-action:active { transform: scale(0.92); }
.btn-action.btn-primary { background-color: var(--primary-color); }
.btn-action.btn-danger { background-color: var(--danger); }
.btn-action.btn-secondary { background-color: var(--surface-light); color: var(--text-muted); }

.input-ios { width: 100%; padding: 18px 16px; background-color: var(--surface-color); border: 1px solid transparent; border-radius: var(--radius-md); color: var(--text-main); font-size: 1.1rem; transition: 0.3s; margin-bottom: 15px; margin-top: 0; flex-shrink: 0;}
.input-ios:focus { border-color: var(--primary-color); background-color: #000; }

/* --- PROFILE & MENU --- */
.profile-upload-area { display: flex; flex-direction: column; align-items: center; margin: 30px 0; flex-shrink: 0;}
.avatar-preview { width: 120px; height: 120px; border-radius: 50%; background-color: var(--surface-color); border: 3px solid var(--primary-color); display: flex; justify-content: center; align-items: center; overflow: hidden; margin-bottom: 15px; font-size: 2rem; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.btn-text { background: none; border: none; color: var(--primary-color); font-size: 1rem; cursor: pointer; font-weight: 500;}
.header-menu { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-shrink: 0; width: 100%;}
.user-info { display: flex; align-items: center; gap: 15px; min-width: 0; flex: 1;}
.mini-avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; background: var(--surface-color); flex-shrink: 0;}
.greeting { font-size: 0.85rem; color: var(--text-muted); }
.header-menu h3 { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.divider { display: flex; align-items: center; text-align: center; margin: 20px 0; color: var(--text-muted); font-size: 0.8rem; font-weight: bold; flex-shrink: 0;}
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--surface-color); }
.divider span { padding: 0 10px; }

/* --- GUIDE SECTION --- */
.guide-section { margin-top: 20px; padding-bottom: 20px; flex-shrink: 0;}
.guide-title { font-size: 0.9rem; margin-bottom: 15px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
.guide-card { margin-bottom: 15px; padding: 18px; background: rgba(28, 28, 30, 0.4); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.05); }
.guide-card h4 { margin-bottom: 12px; color: var(--primary-color); font-size: 1.05rem; }
.guide-steps { list-style: none; padding: 0; }
.guide-steps li { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.guide-steps li span { color: var(--text-main); font-weight: 600; display: inline-block; margin-right: 5px; }
.role-list { display: flex; flex-direction: column; gap: 15px; }
.role-item { display: flex; gap: 15px; align-items: flex-start; }
.role-icon { font-size: 1.4rem; background: var(--surface-light); width: 42px; height: 42px; display: flex; justify-content: center; align-items: center; border-radius: 12px; flex-shrink: 0; box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.role-text { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.role-text strong { color: var(--text-main); font-size: 0.95rem; }

/* --- GAME & LISTS (UI FIX) --- */
.player-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;} 
.player-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; background: var(--surface-light); border-radius: 12px; margin-bottom: 8px; flex-shrink: 0;}
.player-info { display: flex; align-items: center; flex: 1; min-width: 0; gap: 10px; margin-right: 10px;}
.player-info img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0;}
.player-info-text { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 1;}
.player-name-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 0.95rem; font-weight: bold; }
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-shrink: 0;}
.phase-info h3 { margin: 0; font-size: 1.4rem;}
.role-badge { background: rgba(191, 90, 242, 0.2); color: var(--primary-color); padding: 5px 12px; border-radius: 20px; font-weight: bold; font-size: 0.9rem; border: 1px solid var(--primary-color); flex-shrink: 0;}
.instruction-text { text-align: center; color: var(--text-muted); margin-bottom: 15px; font-size: 0.95rem; flex-shrink: 0;}

/* VOTE MARKS UI FIX (LANDSCAPE CENTANG) */
.vote-marks { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; width: 100%;}
.vote-icon { font-size: 0.85rem; }

/* --- CHAT SYSTEM --- */
.chat-container { flex: 1 1 250px; display: flex; flex-direction: column; margin: 10px 0; background: var(--surface-color); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid rgba(255,255,255,0.05); min-height: 250px; flex-shrink: 0;}
.chat-messages { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; list-style: none; scroll-behavior: smooth; -webkit-overflow-scrolling: touch;}
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 18px; font-size: 0.95rem; line-height: 1.4; word-wrap: break-word; flex-shrink: 0;}
.chat-me { align-self: flex-end; background: var(--primary-color); color: white; border-bottom-right-radius: 4px;}
.chat-other { align-self: flex-start; background: var(--surface-light); color: white; border-bottom-left-radius: 4px;}
.chat-sender { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 3px; display: block;}

.chat-input-area { display: flex; align-items: center; padding: 12px 15px; background: var(--surface-light); gap: 10px; flex-shrink: 0; width: 100%; box-sizing: border-box; border-top: 1px solid rgba(255,255,255,0.05);}
.chat-input-area input { flex: 1; min-width: 0; margin: 0; padding: 12px 18px; border-radius: 25px; font-size: 1rem; border: 1px solid rgba(255,255,255,0.1); background: var(--bg-color); color: white; transition: 0.3s;}
.chat-input-area input:focus { border-color: var(--primary-color); background: #000; box-shadow: 0 0 8px rgba(191, 90, 242, 0.3);}
.chat-input-area button { flex: 0 0 auto; min-width: 70px; height: 44px; margin: 0; padding: 0 15px; border-radius: 22px; font-size: 0.95rem; font-weight: bold; background: var(--primary-color); color: white; border: none; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 10px rgba(191, 90, 242, 0.3); transition: 0.2s;}
.chat-input-area button:active { transform: scale(0.92); box-shadow: 0 2px 5px rgba(191, 90, 242, 0.3);}

/* --- SETTINGS MODAL --- */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10000; display: flex; align-items: flex-end; justify-content: center;}
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); transition: opacity 0.3s;}
.modal-content { position: relative; background: var(--surface-color); width: 100%; max-width: 430px; padding: 20px 24px 40px; border-radius: 30px 30px 0 0; animation: slideUpModal 0.3s cubic-bezier(0.17, 0.88, 0.32, 1.1); padding-bottom: max(40px, env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,0.5); max-height: 85dvh; display: flex; flex-direction: column;}
.modal-handle { width: 40px; height: 5px; background: #444; border-radius: 3px; margin: 0 auto 20px; flex-shrink: 0;}
@keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* --- TOAST --- */
#toastContainer { position: fixed; top: env(safe-area-inset-top, 20px); left: 50%; transform: translateX(-50%); z-index: 99999; display: flex; flex-direction: column; gap: 10px; width: 90%; max-width: 400px; pointer-events: none;}
.toast { background: rgba(28, 28, 30, 0.95); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); color: white; padding: 14px 20px; border-radius: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); font-size: 0.95rem; font-weight: 500; text-align: center; animation: slideDown 0.4s cubic-bezier(0.25, 1, 0.5, 1), fadeOut 0.4s 2.6s forwards; border: 1px solid rgba(255,255,255,0.1); }
@keyframes slideDown { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

.confirm-modal { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 100000; display:flex; justify-content:center; align-items:center; opacity: 0; visibility: hidden; transition: 0.3s ease;}
.confirm-modal.active { opacity: 1; visibility: visible; }
.confirm-box { background: var(--surface-color); padding: 25px; border-radius: 20px; width: 85%; max-width: 320px; text-align: center; transform: scale(0.8); transition: 0.3s cubic-bezier(0.17, 0.88, 0.32, 1.27); border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 10px 40px rgba(0,0,0,0.5);}
.confirm-modal.active .confirm-box { transform: scale(1); }
.confirm-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 10px; color: var(--text-main);}
.confirm-desc { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 25px; line-height:1.4;}
.confirm-actions { display: flex; gap: 10px; width: 100%;}
.confirm-actions button { flex: 1; }

.verified-badge { width: 11px; height: 11px; margin-left: 2px; vertical-align: middle;}
.rank-number { font-weight: bold; color: var(--primary-color); width: 25px; font-size: 1.1rem; flex-shrink: 0;}
.trophy-text { color: #FFD700; font-weight: bold; font-size: 0.9rem; display: flex; align-items: center; gap: 5px; flex-shrink: 0;}
.coin-text { color: #32D74B; font-weight: bold; font-size: 0.9rem; display: flex; align-items: center; gap: 5px; flex-shrink: 0;}
.custom-title-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 6px; margin-left: 4px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle; display: inline-block; flex-shrink: 0;}

#globalLoader { position: fixed; top:0; left:0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 999999; display: flex; justify-content: center; align-items: center; }
.spinner { width: 50px; height: 50px; border: 5px solid rgba(191, 90, 242, 0.2); border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.podium-container { background: var(--surface-light); padding: 15px; border-radius: 12px; margin-top: 15px; border: 1px solid rgba(255,255,255,0.05); }
.podium-list { list-style: none; padding: 0; margin: 0; text-align: left; max-height: 250px; overflow-y: auto; -webkit-overflow-scrolling: touch;}
.podium-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); flex-shrink: 0;}
.podium-list li:last-child { border-bottom: none; }
.podium-role { font-size: 0.75rem; font-weight: bold; background: rgba(0,0,0,0.3); padding: 4px 8px; border-radius: 8px; border: 1px solid currentColor; flex-shrink: 0;}

/* WD HISTORY UI */
.wd-history-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; text-align: left; -webkit-overflow-scrolling: touch;}
.wd-history-list li { background: rgba(255,255,255,0.05); padding: 10px; border-radius: 10px; margin-bottom: 8px; font-size: 0.85rem; border: 1px solid rgba(255,255,255,0.05); flex-shrink:0;}
.wd-success { color: #32D74B; font-weight: bold;}
.wd-pending { color: var(--warning); font-weight: bold;}