/* =============================================
   $VIRUS — Game Styles
   ============================================= */

body {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
}

/* ----- APP CONTAINER ----- */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-primary);
    box-shadow: 0 0 60px rgba(74, 122, 255, 0.08);
}

/* ----- HEADER ----- */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: rgba(10, 10, 26, 0.95);
    border-bottom: 1px solid var(--border-color);
    z-index: 20;
    backdrop-filter: blur(20px);
    min-height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-red), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    -webkit-text-fill-color: initial;
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(255, 51, 102, 0.5));
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info .points {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-gold);
}

.user-info .level-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.user-info .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: transform var(--transition);
}

.user-info .avatar:active {
    transform: scale(0.9);
}

/* ----- GAME AREA ----- */
#game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at center, #0d1b2a, #050510);
}

#globe-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#globe-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ----- STATS OVERLAY ----- */
#stats-overlay {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    z-index: 15;
    pointer-events: none;
}

.stat-badge {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    min-width: 60px;
}

.stat-badge .label {
    color: var(--text-secondary);
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-badge .value {
    font-weight: 700;
    font-size: 14px;
}

.stat-badge .value.red { color: var(--accent-red); }
.stat-badge .value.green { color: var(--accent-green); }
.stat-badge .value.gold { color: var(--accent-gold); }
.stat-badge .value.blue { color: var(--accent-blue); }

/* ----- DAILY BONUS BANNER ----- */
.daily-bonus-banner {
    position: absolute;
    top: 70px;
    left: 12px;
    right: 12px;
    z-index: 15;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(74, 122, 255, 0.3));
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--accent-purple);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 15px rgba(139, 92, 246, 0.6); }
}

/* ----- VACCINE BAR ----- */
#vaccine-bar {
    position: absolute;
    bottom: 80px;
    left: 16px;
    right: 16px;
    z-index: 15;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

#vaccine-bar .header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

#vaccine-bar .header .percent {
    color: var(--accent-red);
    font-weight: 600;
}

#vaccine-bar .track {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

#vaccine-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #66ff88, #ffaa00, #ff3366);
    width: 0%;
}

/* ----- BOTTOM NAV ----- */
#bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(10, 10, 26, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    min-height: 64px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 10px;
    position: relative;
    min-width: 56px;
}

.nav-item .icon {
    font-size: 22px;
    transition: transform var(--transition);
}

.nav-item .label {
    font-size: 9px;
}

.nav-item.active {
    color: var(--accent-blue);
}

.nav-item.active .icon {
    transform: scale(1.15);
}

.nav-item .badge {
    position: absolute;
    top: 0;
    right: 2px;
    background: var(--accent-red);
    color: #fff;
    font-size: 9px;
    border-radius: 50%;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    font-weight: 700;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ----- PAGES ----- */
.page {
    display: none;
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 30;
    padding-top: calc(60px + env(safe-area-inset-top, 0px));
    overflow-y: auto;
    max-width: 480px;
    width: 100%;
    animation: slideUp 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(30px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.page-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 18px;
    font-weight: 700;
    position: sticky;
    top: calc(60px + env(safe-area-inset-top, 0px));
    background: var(--bg-primary);
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    font-size: 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 5;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* ----- LEADERBOARD ----- */
.leaderboard-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
}

.tab-btn {
    flex: 1;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: #fff;
    border-color: transparent;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition);
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-item .rank {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-secondary);
    min-width: 28px;
    text-align: center;
}

.leaderboard-item .rank.top1 { color: var(--accent-gold); }
.leaderboard-item .rank.top2 { color: #c0c0c0; }
.leaderboard-item .rank.top3 { color: #cd7f32; }

.leaderboard-item .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.leaderboard-item .info {
    flex: 1;
    min-width: 0;
}

.leaderboard-item .info .name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-item .info .sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.leaderboard-item .score {
    font-weight: 700;
    color: var(--accent-gold);
    flex-shrink: 0;
}

.leaderboard-item.is-me {
    background: rgba(74, 122, 255, 0.08);
    border-left: 3px solid var(--accent-blue);
}

/* ----- CLANS ----- */
.clan-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin: 8px 16px;
    border: 1px solid var(--border-color);
    transition: background var(--transition);
}

.clan-card:hover {
    background: rgba(26, 26, 53, 0.9);
}

.clan-card .clan-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.clan-card .clan-info {
    flex: 1;
    min-width: 0;
}

.clan-card .clan-info .name {
    font-weight: 600;
}

.clan-card .clan-info .members {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ----- QUESTS / ACHIEVEMENTS ----- */
.quest-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.quest-item .icon {
    font-size: 24px;
    flex-shrink: 0;
}

.quest-item .info {
    flex: 1;
    min-width: 0;
}

.quest-item .info .title {
    font-weight: 500;
    font-size: 14px;
}

.quest-item .info .desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.quest-item .progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}

.quest-item .progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    transition: width 0.5s ease;
}

.quest-item .progress-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.quest-item .reward {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-gold);
    flex-shrink: 0;
}

.quest-item.completed .info .title {
    color: var(--accent-green);
}

.quest-item.completed .info .desc {
    text-decoration: line-through;
    opacity: 0.6;
}

/* ----- SHOP ----- */
.shop-balance {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.shop-balance .shop-points {
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 16px;
    margin-left: 8px;
}

/* ----- MODALS ----- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.modal-overlay .modal {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2, .modal-header h3 {
    font-size: 18px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Chat modal */
.chat-modal {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 12px;
    min-height: 200px;
}

.chat-msg {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.chat-msg .chat-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-blue);
}

.chat-msg .chat-role {
    font-size: 10px;
    color: var(--accent-gold);
    margin-left: 6px;
}

.chat-msg .chat-text {
    font-size: 14px;
    margin-top: 2px;
    word-break: break-word;
}

.chat-msg .chat-time {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-form {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    margin: 0 !important;
}

/* Prompt / Confirm modals */
.prompt-modal {
    text-align: center;
}

.prompt-modal h3 {
    margin-bottom: 8px;
}

.prompt-modal p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

.prompt-input {
    margin-bottom: 16px !important;
    text-align: center;
    font-size: 16px !important;
}

.prompt-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Achievement toast */
.achievement-toast {
    position: fixed;
    top: calc(80px + env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    z-index: 60;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(255, 170, 0, 0.3));
    backdrop-filter: blur(15px);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.5s ease;
    box-shadow: 0 4px 20px rgba(255, 170, 0, 0.2);
}

.achievement-toast .ach-icon {
    font-size: 32px;
}

.achievement-toast .ach-title {
    font-size: 11px;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievement-toast .ach-name {
    font-size: 14px;
    font-weight: 600;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Click effect */
.click-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 700;
    color: var(--accent-red);
    pointer-events: none;
    z-index: 100;
    animation: floatUp 1s ease forwards;
    text-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
    white-space: nowrap;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1.5); }
}

/* Loading */
#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    z-index: 20;
    background: rgba(0, 0, 0, 0.8);
    padding: 20px 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-blue);
    text-align: center;
}

.loading-icon {
    font-size: 48px;
    margin-bottom: 8px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ----- CLAN PROFILE SECTION ----- */
.clan-profile {
    text-align: center;
    padding: 20px 16px;
}

.clan-profile .clan-emoji {
    font-size: 64px;
}

.clan-profile .clan-name {
    font-size: 24px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.clan-profile .clan-tag {
    color: var(--text-secondary);
    font-size: 14px;
}

.clan-stats-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 16px 0;
}

.clan-stat {
    text-align: center;
}

.clan-stat .clan-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.clan-stat .clan-stat-value {
    font-size: 18px;
    font-weight: 700;
}

.clan-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* ----- PROFILE SECTION ----- */
.profile-header {
    text-align: center;
    padding: 20px 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    margin: 0 auto 12px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
}

.profile-level {
    color: var(--accent-purple);
    font-size: 14px;
    margin-top: 4px;
}

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 16px 0;
}

.profile-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.profile-stat-card .ps-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.profile-stat-card .ps-value {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}

.exp-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.exp-bar .exp-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    transition: width 0.5s ease;
}

.referral-section {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-color);
}

.referral-section .ref-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.referral-link {
    display: flex;
    gap: 8px;
}

.referral-link code {
    flex: 1;
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-blue);
}

.profile-tabs {
    display: flex;
    gap: 4px;
    margin: 16px 0 12px;
}

.profile-tab {
    flex: 1;
    padding: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    font-family: inherit;
}

.profile-tab.active {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: #fff;
    border-color: transparent;
}

/* ----- EMPTY STATE ----- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state .empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state .empty-desc {
    font-size: 14px;
    margin-bottom: 16px;
}

/* ----- RESPONSIVE ----- */
@media (max-width: 480px) {
    .stat-badge {
        padding: 4px 8px;
        font-size: 10px;
        min-width: 50px;
    }
    .stat-badge .value {
        font-size: 12px;
    }
    .logo {
        font-size: 16px;
    }
    .nav-item {
        padding: 4px 8px;
        font-size: 9px;
        min-width: 44px;
    }
    .nav-item .icon {
        font-size: 18px;
    }
    .clan-stats-row {
        gap: 12px;
    }
    .clan-stat .clan-stat-value {
        font-size: 16px;
    }
}