/* ==========================================================================
   🌌 BASE STRUCTURAL & HOLOGRAPHIC STYLE FRAMEWORK
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}
body {
    background-color: #04060c;
    color: #f8fafc;
    font-family: 'Segoe UI', Monaco, monospace;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

.page-bg-overlay {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(2, 6, 23, 0.55), rgba(2, 6, 23, 0.75)), url('/bak/images/mac6.png');
    background-size: cover;
    background-position: center;
    opacity: 0.85;
    z-index: -2;
    pointer-events: none;
}

#game-container {
    position: relative;
    width: 1024px;
    height: 576px;
    background: #020408;
    border: 2px solid #1e293b;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #0b0f19 0%, #020408 100%);
}

/* ==========================================================================
   🔒 SECURE LOGIN & SCREEN OVERLAYS
   ========================================================================== */
.screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 4, 8, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.neon-title {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    color: #fff;
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
    margin-bottom: 24px;
}

.structural-panel {
    width: 100%;
    padding: 24px;
    background: rgba(10, 15, 30, 0.7);
    border: 1px solid #38bdf833;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.auth-input {
    width: 100%;
    background: rgba(2, 4, 8, 0.9);
    border: 1px solid #38bdf855;
    padding: 12px;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    border-radius: 4px;
    margin-bottom: 12px;
    outline: none;
    transition: all 0.2s ease;
}
.auth-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

#auth-error-msg {
    font-size: 12px;
    margin-bottom: 12px;
    display: none;
    font-family: monospace;
}

#auth-toggle-mode {
    font-size: 11px;
    color: #64748b;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 14px;
    transition: color 0.2s ease;
}
#auth-toggle-mode:hover {
    color: #38bdf8;
}

.menu-btn {
    width: 100%;
    background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    color: white;
    padding: 12px;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: 1px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}
.menu-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.5);
}
.menu-btn:active {
    transform: translateY(1px);
}

.lobby-foreground {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lobby-profile-header {
    width: min(560px, 88vw);
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 12px;
    background: rgba(2, 6, 23, 0.55);
}

.lobby-avatar {
    width: 82px;
    height: 82px;
    border-radius: 14px;
    border: 2px solid rgba(56, 189, 248, 0.75);
    object-fit: cover;
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

.lobby-profile-bars {
    display: grid;
    gap: 6px;
}

.lobby-bar-label {
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
    color: #cbd5e1;
    letter-spacing: 0.8px;
}

.lobby-progress-wrap {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.lobby-progress-fill {
    height: 100%;
    width: 0%;
    transition: width 0.25s ease;
}

.lobby-progress-fill.hp {
    background: linear-gradient(90deg, #ef4444, #f97316);
}

.lobby-progress-fill.xp {
    background: linear-gradient(90deg, #22d3ee, #3b82f6);
}

.avatar-upload-row {
    width: min(560px, 88vw);
    display: grid;
    grid-template-columns: 1fr 170px;
    gap: 8px;
    margin-bottom: 14px;
}

.avatar-input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: rgba(2, 6, 23, 0.75);
    color: #e2e8f0;
    font-family: monospace;
    font-size: 12px;
}

.avatar-upload-btn {
    width: 100%;
    padding: 10px;
}

.leaderboard-overlay {
    position: absolute;
    inset: 24px;
    z-index: 1;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.52), rgba(30, 41, 59, 0.36));
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 14px;
    overflow: hidden;
}

.leaderboard-overlay-title {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1.8px;
    color: #cbd5e1;
    margin-bottom: 10px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 70%;
    overflow-y: auto;
    padding-right: 4px;
}

.leaderboard-row {
    display: grid;
    grid-template-columns: 52px 1fr 110px 76px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(2, 6, 23, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    font-family: monospace;
    font-size: 12px;
    color: #e2e8f0;
}

.leaderboard-rank {
    color: #7dd3fc;
    font-weight: 700;
}

.leaderboard-profile-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.leaderboard-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 2px 8px rgba(2, 6, 23, 0.85), 0 0 0 1px rgba(148, 163, 184, 0.14);
    background: radial-gradient(circle at 32% 24%, rgba(51, 65, 85, 0.95), rgba(15, 23, 42, 1));
    transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
    flex-shrink: 0;
}

.leaderboard-row:hover .leaderboard-avatar {
    border-color: rgba(125, 211, 252, 0.9);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.5), 0 3px 10px rgba(2, 6, 23, 0.95);
    transform: translateY(-1px);
}

.leaderboard-name {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-stats {
    color: #cbd5e1;
    text-align: right;
}

.leaderboard-score {
    color: #facc15;
    font-weight: 800;
    text-align: right;
}

.leaderboard-empty {
    margin-top: 8px;
    color: #94a3b8;
    font-family: monospace;
    font-size: 12px;
}

@media (max-width: 900px) {
    .lobby-profile-header {
        grid-template-columns: 72px 1fr;
        width: 95%;
        margin-top: 8px;
    }

    .lobby-avatar {
        width: 66px;
        height: 66px;
    }

    .avatar-upload-row {
        width: 95%;
        grid-template-columns: 1fr;
    }

    .leaderboard-overlay {
        inset: 12px;
        padding: 10px;
    }

    .leaderboard-row {
        grid-template-columns: 45px 1fr 95px 65px;
        font-size: 11px;
        padding: 6px 8px;
    }

    .leaderboard-avatar {
        width: 26px;
        height: 26px;
    }
}

/* ==========================================================================
   📊 HEADS UP DISPLAY (HUD) MODULATORS
   ========================================================================== */
#game-hud {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}
.hud-panel {
    background: rgba(10, 15, 30, 0.6);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px 14px;
    border-radius: 6px;
    width: 220px;
    backdrop-filter: blur(4px);
}
.hud-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 6px;
    color: #94a3b8;
}
.bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 3px;
    margin-bottom: 4px;
    overflow: hidden;
}
.hud-bar {
    height: 100%;
    width: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.hp-fill { background: #ef4444; box-shadow: 0 0 8px #ef444499; }
.fuel-fill { background: #eab308; box-shadow: 0 0 8px #eab30899; }

/* ==========================================================================
   🎛️ COGNITIVE COMBAT ABILITY CARD TRAY
   ========================================================================== */
#ability-tray-wrapper {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
}

#ability-card-tray {
    display: flex;
    gap: 8px;
    background: rgba(4, 6, 12, 0.6);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ability-card {
    position: relative;
    width: 95px;
    height: 110px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.ability-card:hover {
    border-color: var(--theme-color) !important;
    box-shadow: 0 0 20px var(--theme-color) !important;
    transform: translateY(-6px);
}
.ability-card.selected {
    border-color: var(--theme-color) !important;
    transform: translateY(-4px);
}

.card-bind {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 9px;
    font-family: monospace;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 900;
}

.card-icon-frame {
    width: 100%;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 8px;
}
.card-icon {
    font-size: 22px;
    transition: transform 0.2s ease;
}
.ability-card:hover .card-icon {
    transform: scale(1.2) rotate(4deg);
}

.card-title {
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f1f5f9;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8px;
    font-family: monospace;
    font-weight: 600;
    margin-top: 2px;
}

.cd-badge {
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 4px;
    border-radius: 2px;
    color: #94a3b8;
}