:root {
    --bg-dark: #020617;
    --panel-bg: rgba(15, 23, 42, 0.7);
    --gold: #fbbf24;
    --health: #f43f5e;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.5);
    --text: #f1f5f9;
    --glass-border: rgba(255, 255, 255, 0.12);
    --neon-cyan: #22d3ee;
    --neon-purple: #a855f7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Global Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--accent), #4f46e5);
    border: 2px solid rgba(15, 23, 42, 0.8);
    border-radius: 10px;
    box-shadow: 0 0 10px var(--accent-glow);
}

::-webkit-scrollbar-thumb:hover {
    background: #818cf8;
}

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(15, 23, 42, 0.3);
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(1px 1px at 20px 30px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(1px 1px at 40px 70px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(1.5px 1.5px at 50px 160px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(1px 1px at 130px 80px, #fff, rgba(0, 0, 0, 0)),
        radial-gradient(1.5px 1.5px at 160px 120px, #fff, rgba(0, 0, 0, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.15;
    animation: starsRotate 200s linear infinite;
    pointer-events: none;
}

@keyframes starsRotate {
    from {
        transform: rotate(0deg) scale(1);
    }

    to {
        transform: rotate(360deg) scale(1.5);
    }
}

#game-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
    background: transparent;
    touch-action: none;
}

#gameCanvas {
    display: none;
    width: 100%;
    height: 100%;
}

#demoCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* HUD Styling */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 15px;
    pointer-events: none;
    z-index: 1000;
}

#abandon-btn {
    pointer-events: auto;
}

.stat-box {
    background: var(--panel-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-radius: 0 0 10px 10px;
    border: 1px solid var(--glass-border);
    border-top: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#gold-display {
    color: var(--gold);
}

#lives-display {
    color: var(--health);
}

/* Shop Styling (Bottom Bar Warcraft 3 style) */
#shop {
    display: none;
    width: 100%;
    height: 180px;
    background: rgba(10, 15, 30, 0.98);
    border-top: 2px solid var(--accent);
    flex-direction: row;
    z-index: 2500;
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 -15px 40px rgba(0,0,0,0.6);
}

.mini-stat-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 600;
}

.mini-stat-badge span {
    font-weight: 800;
}

.upgrade-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.upgrade-action-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
    box-shadow: 0 8px 15px rgba(0,0,0,0.4);
}

.upgrade-action-btn:active {
    transform: scale(0.95);
}

.upgrade-action-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    transform: none !important;
}

#shop.active {
    display: flex;
}

#shop-tabs {
    display: flex;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--glass-border);
    height: 35px;
}

.shop-tab {
    flex: 1;
    padding: 8px 5px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    opacity: 0.4;
    transition: all 0.2s;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop-tab.active {
    opacity: 1;
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 3px solid var(--accent);
}

.shop-content {
    display: none;
    padding: 8px;
    gap: 8px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    flex-grow: 1;
    width: 100%;
    overflow-y: auto;
    overflow-y: auto;
    box-sizing: border-box;
}

.shop-content.active {
    display: flex !important;
}

.shop-content::-webkit-scrollbar {
    width: 6px;
}

.shop-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.shop-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.shop-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    margin-bottom: 5px;
}

.shop-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.shop-item.unaffordable {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.shop-item.locked {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%) blur(1px);
    background: rgba(0, 0, 0, 0.4);
}

.shop-item.locked::after {
    content: '🔒';
    position: absolute;
    font-size: 1.2rem;
    color: white;
    text-shadow: 0 0 5px black;
    opacity: 0.8;
}

.shop-item.selected {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}


.icon-preview {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.shop-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.icon-preview.fast-merc { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.icon-preview.tank-merc { background: #64748b; box-shadow: 0 0 10px #64748b; }
.icon-preview.boss-merc { background: #a855f7; box-shadow: 0 0 10px #a855f7; }

/* The rest is removed as we handle labels in the profile area now */
#diamonds-display { color: #a78bfa; }

/* Menus & Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000; /* Default for popups like HOF, Shop */
    transition: opacity 0.3s ease;
}

.overlay.screen {
    z-index: 1000; /* Base layers for Lobby, Room, Auth */
}

/* System critical layers that must be above everything */
#disconnect-modal, #maintenance-modal, #avatar-selector-modal, #abandon-modal {
    z-index: 10000 !important;
}

.hidden {
    display: none !important;
}

.overlay.hidden {
    display: none !important;
    opacity: 0;
}


/* Centralized glissement (sliding) for all modals in overlays */
.overlay:not(.hidden) > .modal {
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Navigation screens: fade in/out instead of display:none */
.screen {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.screen-hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.modal {
    background: rgba(15, 23, 42, 0.85);
    padding: 35px 30px;
    border-radius: 28px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-width: 95vw;
    width: auto;
    position: relative;
    overflow: hidden;
}

.modal h1,
.modal h2 {
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
    color: #fff;
}

.game-title {
    font-size: 2.5rem !important;
    margin-bottom: 10px !important;
    background: linear-gradient(to bottom, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

.game-subtitle {
    opacity: 0.6 !important;
    font-size: 0.9rem !important;
    margin-bottom: 30px !important;
    letter-spacing: 2px !important;
    text-transform: uppercase !important;
    color: var(--accent) !important;
}

.game-input {
    padding: 14px 18px;
    margin-bottom: 15px;
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.2s;
}

.game-input:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 15px var(--accent-glow) !important;
}

select.game-input option {
    background-color: #0f172a;
    color: white;
}

.game-card {
    background: rgba(0, 0, 0, 0.2) !important;
    padding: 20px !important;
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    margin: 20px 0 !important;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row.highlight {
    background: rgba(99, 102, 241, 0.1) !important;
    border-left: 3px solid var(--accent);
}

.stat-item {
    display: flex;
    flex-direction: column;
    min-width: 80px;
    margin: 5px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text);
}

.accent-text {
    color: var(--accent) !important;
    font-weight: bold !important;
}

button {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
    filter: brightness(1.1);
}

button:active {
    transform: translateY(1px) scale(0.98);
}

.auth-modal {
    max-width: 480px;
    width: 95%;
    padding: 50px 40px;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(99, 102, 241, 0.1);
    position: relative;
    overflow: visible; /* To allow deco elements to pop out if needed */
}

.auth-header {
    margin-bottom: 40px;
}

.auth-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-inputs-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    width: 100%;
}

.input-container {
    position: relative;
    width: 100%;
}


.input-focus-line {
    position: absolute;
    bottom: 15px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: all 0.3s ease;
    transform: translateX(-50%);
    box-shadow: 0 0 10px var(--accent);
}

.game-input:focus + .input-focus-line {
    width: 80%;
}

.divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 10px 0;
    opacity: 0.4;
    font-size: 0.8rem;
    font-weight: 800;
}

.divider::before, .divider::after {
    content: "";
    flex-grow: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.2), transparent);
}

button.glow-btn {
    position: relative;
    overflow: hidden;
}

button.glow-btn::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

button.glow-btn:hover::after {
    opacity: 1;
}

.primary-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, #4338ca 100%);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    padding: 16px !important;
}

.secondary-btn {
    width: 100%;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    box-shadow: none;
}

.secondary-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    color: white;
}

.tertiary-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    box-shadow: none;
    font-size: 0.9rem !important;
}

.text-link-btn {
    background: none !important;
    box-shadow: none !important;
    text-decoration: underline;
    font-size: 0.85rem;
    opacity: 0.6;
    padding: 0 !important;
    margin-top: 20px;
    text-transform: none;
    letter-spacing: normal;
}

.text-link-btn:hover {
    opacity: 1;
    transform: none;
    background: none;
    box-shadow: none;
}

.auth-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hidden-section {
    display: none;
    width: 100%;
    margin-top: 20px;
    animation: fadeInSlideUp 0.3s forwards;
}

@keyframes fadeInSlideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-actions {
    display: flex;
    gap: 10px;
}

.accent-btn {
    flex: 1;
    background: var(--accent);
}

.back-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Auth background decorations */
.auth-bg-deco {
    position: absolute;
    border-radius: 50%;
    z-index: -1;
    filter: blur(40px);
}

.deco-1 {
    top: 10%;
    right: -5%;
    width: 150px;
    height: 150px;
    background: var(--accent);
    opacity: 0.2;
    animation: decoFloat 10s infinite ease-in-out;
}

.deco-2 {
    bottom: 5%;
    left: -10%;
    width: 200px;
    height: 200px;
    background: var(--neon-purple);
    opacity: 0.15;
    animation: decoFloat 15s infinite ease-in-out reverse;
}

@keyframes decoFloat {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, 30px); }
}

/* Staggered entry */
.stagger-group > * {
    opacity: 0;
    animation: staggerFadeIn 0.5s forwards;
}

.stagger-group > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-group > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-group > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-group > *:nth-child(4) { animation-delay: 0.4s; }

@keyframes staggerFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive auth adjustments */
@media screen and (max-width: 768px) {
    .auth-modal {
        padding: 35px 25px;
    }
    .input-preview-group {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
}

#upgrade-menu {
    position: absolute;
    background: var(--panel-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 150px;
}

#mobile-incompatibility {
    display: none;
    z-index: 2000;
}

/* Show on screens < 768px */
@media screen and (max-width: 768px) {
    #mobile-incompatibility {
        display: flex !important;
    }
}

.hidden {
    display: none !important;
}

.reg-avatar-choice {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    object-fit: cover;
    background: rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.reg-avatar-choice:hover {
    transform: scale(1.1);
    border-color: rgba(167, 139, 250, 0.5);
}

.reg-avatar-choice.selected-avatar {
    border-color: #a78bfa;
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.6);
}

/* Slide-up entrance for modals inside screens */
@keyframes screenFadeSlide {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.screen:not(.screen-hidden)>.modal {
    animation: screenFadeSlide 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

#upgrade-menu .spec-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: none;
    letter-spacing: normal;
}

#upgrade-menu #upgrade-rapid {
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.1) 0%, rgba(234, 179, 8, 0.05) 100%);
    border-color: rgba(234, 179, 8, 0.3);
}

#upgrade-menu #upgrade-heavy {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(185, 28, 28, 0.05) 100%);
    border-color: rgba(185, 28, 28, 0.3);
}

#upgrade-menu .spec-btn:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.1);
}

#upgrade-menu #upgrade-rapid:hover {
    border-color: #facc15;
    box-shadow: 0 5px 15px rgba(250, 204, 21, 0.2);
}

#upgrade-menu #upgrade-heavy:hover {
    border-color: #ef4444;
    box-shadow: 0 5px 15px rgba(239, 68, 68, 0.2);
}

#upgrade-menu button.unaffordable-btn {
    opacity: 0.55;
    background: rgba(0, 0, 0, 0.4) !important;
    color: #ef4444 !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    cursor: not-allowed !important;
    transform: none !important;
    filter: none !important;
}

#special-upgrade.hidden {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 800px) {
    #game-container {
        width: 100vw;
        height: 100vh;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
    }

    .modal h1 {
        font-size: 1.8rem;
    }

    .modal {
        padding: 20px 15px;
    }

    button {
        padding: 10px 20px;
        font-size: 1rem;
    }

    #room-screen .modal {
        flex-direction: column;
        overflow-y: auto;
        max-height: 90vh;
    }

    #room-screen .modal>div {
        flex: none !important;
        width: 100%;
    }

    #hud {
        top: 5px;
        top: calc(5px + env(safe-area-inset-top));
        left: 5px;
        right: 5px;
        gap: 5px;
        pointer-events: none;
        justify-content: flex-start;
        z-index: 1000 !important;
    }

    .stat-box {
        padding: 4px 10px;
        font-size: 0.7rem;
        gap: 4px;
        background: rgba(15, 23, 42, 0.9);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    #abandon-btn {
        padding: 6px 12px !important;
        font-size: 0.7rem !important;
        pointer-events: auto;
    }
}

#boss-alert {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ef4444;
    font-size: 5rem;
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.5s;
    animation: pulse-red 1s infinite;
}

#boss-alert.visible {
    opacity: 1;
}

@keyframes pulse-red {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.1);
        filter: brightness(1.5);
    }
}

/* Leaderboard Styling */
#leaderboard {
    position: absolute;
    top: 60px;
    right: 15px;
    background: var(--panel-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    min-width: 180px;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.leaderboard-header {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text);
    opacity: 0.5;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.leaderboard-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    gap: 15px;
}

.leaderboard-name {
    font-weight: 400;
    color: var(--text);
}

.leaderboard-score {
    font-weight: 700;
    color: var(--gold);
}

.leaderboard-row.me .leaderboard-name {
    color: var(--primary);
    font-weight: 700;
}

.leaderboard-row.eliminated {
    opacity: 0.4;
}

.leaderboard-row.eliminated .leaderboard-name {
    text-decoration: line-through;
    color: #ef4444;
}

/* Notification Toast */
.elimination-toast {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    z-index: 2000;
    animation: slide-down-up 3s forwards;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    pointer-events: none;
}

@keyframes slide-down-up {
    0% {
        transform: translate(-50%, -20px);
        opacity: 0;
    }

    10% {
        transform: translate(-50%, 0);
        opacity: 1;
    }

    90% {
        transform: translate(-50%, 0);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -20px);
        opacity: 0;
    }
}

.hof-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.hof-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.hof-row td {
    padding: 16px 24px;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.8);
}

.hof-rank {
    font-weight: 800;
    color: #94a3b8;
}

.hof-rank.top-1 { color: #f59e0b; font-size: 1.1rem; }
.hof-rank.top-2 { color: #e2e8f0; }
.hof-rank.top-3 { color: #d97706; }

.hof-username {
    font-weight: 600;
    color: white;
}

.hof-wave {
    text-align: center;
    font-family: monospace;
    color: #a78bfa;
    font-weight: bold;
}

.hof-score {
    text-align: right;
    font-weight: 800;
    color: #fbbf24;
}

.loading,
.no-data {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-style: italic;
}

/* Specific HOF styles (leaving non-animation ones) */


/* ============ DIAMOND SHOP ============ */
#diamond-shop {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    border: 1px solid rgba(167, 139, 250, 0.3);
    box-shadow: 0 0 60px rgba(139, 92, 246, 0.15), 0 25px 50px rgba(0, 0, 0, 0.5);
}

/* Avatar images in shop and HUD */
#diamond-shop-avatars .diamond-pack img {
    object-fit: contain;
    background: rgba(255,255,255,0.03);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    transition: transform 0.2s, filter 0.2s;
}
#diamond-shop-avatars .diamond-pack:hover img {
    transform: scale(1.08);
    filter: brightness(1.1);
}
#lobby-profile-avatar,
#profile-avatar {
    object-fit: contain;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}
#hud-user-avatar {
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
}

.diamond-pack {
    position: relative;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(167, 139, 250, 0.2);
    border-radius: 16px;
    padding: 24px 16px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s, border-color 0.2s;
    opacity: 0.75;
    overflow: hidden;
}

.diamond-pack:hover {
    transform: translateY(-3px);
    border-color: rgba(167, 139, 250, 0.5);
}

.diamond-pack.popular {
    border-color: rgba(167, 139, 250, 0.6);
    background: rgba(139, 92, 246, 0.08);
}

.diamond-pack.legendary {
    border-color: rgba(240, 171, 252, 0.5);
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.1), rgba(245, 158, 11, 0.06));
}

.pack-badge {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #7c3aed, #a855f7);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 0 0 8px 8px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.legendary-badge {
    background: linear-gradient(90deg, #d97706, #f59e0b);
    color: #1a0a00;
}

.pack-gems {
    font-size: 1.4rem;
    letter-spacing: 2px;
    margin-top: 8px;
}

.pack-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e2d9f3;
    margin-top: 4px;
}

.pack-amount {
    font-size: 0.95rem;
    color: #a78bfa;
    font-weight: 600;
}

.pack-bonus {
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 1em;
}

.pack-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: #f8fafc;
    margin: 6px 0 4px;
}

.pack-btn {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: not-allowed;
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.3);
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}

.pack-btn:not([disabled]) {
    cursor: pointer;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border: none;
    color: white;
    transition: filter 0.15s;
}

.pack-btn:not([disabled]):hover {
    filter: brightness(1.15);
}

.legendary-btn:not([disabled]) {
    background: linear-gradient(135deg, #d97706, #f59e0b);
    color: #1a0a00;
}

@media (max-width: 640px) {
    #diamond-shop-modal .pack-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Rules Modal Styles */
.rules-section h2 {
    font-size: 1.3rem;
    margin-top: 10px;
}

.rules-section p,
.rules-section li {
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.rules-section ul {
    list-style-type: none;
    padding-left: 5px !important;
}

.rules-section li::before {
    content: "•";
    color: #f39c12;
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

/* Upgrade Cards */
.upgrade-card {
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex !important;
    flex-direction: column;
}

.upgrade-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.shop-btn {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.shop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.shop-btn:not(:disabled):hover {
    filter: brightness(1.2);
    transform: scale(1.05);
}

.shop-content:not(.active) {
    display: none !important;
}

.shop-content.active {
    display: flex !important;
    justify-content: flex-start !important;
}

#diamond-shop-packs.active {
    display: flex !important;
    flex-direction: column;
}

#diamond-shop-upgrades.active {
    display: block !important;
}

/* PRO MULTIPLAYER LOBBY STYLES */
.lobby-sidebar {
    width: 320px;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 32px;
    padding: 35px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.3),
        inset 0 1px 1px rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for cleaner look */
}

.lobby-sidebar::-webkit-scrollbar {
    display: none;
}

.lobby-main-card {
    flex: 1;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.lobby-header-bar {
    padding: 24px 30px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-card-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.room-entry {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 18px 25px;
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.2fr 1.2fr;
    align-items: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.room-entry:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.room-status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-waiting { 
    background: rgba(16, 185, 129, 0.1); 
    color: #10b981; 
    border: 1px solid rgba(16, 185, 129, 0.2); 
    position: relative;
}

.status-waiting::before {
    content: "";
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 2px;
    display: inline-block;
    animation: lobbyPulse 1.5s infinite;
}

@keyframes lobbyPulse {
    0% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1.1); opacity: 0.8; box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.status-full { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.status-ingame { background: rgba(99, 102, 241, 0.1); color: #6366f1; border: 1px solid rgba(99, 102, 241, 0.2); }

.lobby-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    border: none;
    color: white;
    cursor: pointer;
    font-family: inherit;
}

.btn-create {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.lobby-input-group {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 10px 16px;
    gap: 20px;
    align-items: center;
}

.lobby-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* In-game Chat (Age of Empires Style) */
.ingame-chat-msg {
    color: white;
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         2px  2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    animation: fadeIn 0.3s ease-out;
    line-height: 1.4;
    max-width: 100%;
    word-wrap: break-word;
}

.ingame-chat-msg.fade-out {
    transition: opacity 1s, transform 1s;
    opacity: 0;
    transform: translateX(-10px);
}

#ingame-chat-messages.collapsed {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* Admin Specific Styles */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.admin-stat-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
}

.admin-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
}

.admin-progress-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

.admin-progress-fill {
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: width 0.5s ease-out;
}

.admin-table-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    text-align: left;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1px;
    opacity: 0.6;
}

.admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.admin-toggle-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-slider-container {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 15px;
}

.admin-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    margin: 15px 0;
}

.admin-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Emoji Picker */
.emoji-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2) translateY(-2px);
    filter: drop-shadow(0 5px 8px rgba(0,0,0,0.4));
}

.emoji-btn:active {
    transform: scale(0.9);
}

#ingame-chat-emoji-btn:hover, #admin-chat-emoji-btn:hover, #lobby-chat-emoji-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.3));
}

#ingame-emoji-picker, #admin-emoji-picker, #lobby-emoji-picker {
    animation: emojiPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes emojiPop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.85);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.live-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    position: relative;
    box-shadow: 0 0 10px #10b981;
}

.live-pulse::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #10b981;
    opacity: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

.audit-filter-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.4);
    transition: all 0.2s;
}

.audit-filter-btn:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.audit-filter-btn.active {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}

/* Mod context menu */
.context-menu {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 6px;
    z-index: 10000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.context-menu button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.context-menu button:hover {
    background: rgba(255,255,255,0.05);
}

.context-menu button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
