body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #222;
}

canvas {
    display: block;
}

#ui-layer {
    position: absolute;
    top: 10px;
    left: 10px;
    pointer-events: none; /* 让鼠标事件穿透到 Canvas */
    color: white;
    font-family: 'Microsoft YaHei', sans-serif;
    user-select: none;
}

.instructions {
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
}

#gold-display {
    font-size: 24px;
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 2px 2px 2px #000;
}

#stats-display {
    color: white;
    font-size: 18px;
    margin-top: 5px;
    text-shadow: 1px 1px 1px #000;
}

#death-shop-btn {
    position: absolute;
    top: 60px;
    right: 10px;
    background: #c0392b;
    color: white;
    border: 2px solid #fff;
    padding: 8px 15px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 50;
    font-weight: bold;
    animation: pulse 2s infinite;
}

#death-shop-btn:hover {
    background: #e74c3c;
}

#music-btn {
    margin-top: 10px;
    background: #34495e;
    color: white;
    border: 1px solid #7f8c8d;
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 5px;
    cursor: pointer;
    pointer-events: auto; /* Re-enable pointer events for button */
}

#music-btn:hover {
    background: #2c3e50;
}

/* 排行榜样式 */
#leaderboard {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 250px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #7f8c8d;
    border-radius: 5px;
    color: white;
    font-family: 'Microsoft YaHei', sans-serif;
    padding: 10px;
    pointer-events: none;
    z-index: 40;
}

#leaderboard h3 {
    margin: 0 0 10px 0;
    text-align: center;
    color: #f1c40f;
    font-size: 18px;
    border-bottom: 1px solid #7f8c8d;
    padding-bottom: 5px;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

.rank-num {
    width: 20px;
    font-weight: bold;
    color: #bdc3c7;
}

.player-name {
    flex-grow: 1;
    text-align: left;
    padding-left: 10px;
}

.player-kills {
    font-weight: bold;
    color: #e74c3c;
}

.is-me {
    color: #f1c40f; /* 高亮自己 */
    font-weight: bold;
}

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

/* 商店样式 */
.hidden {
    display: none !important;
}

#shop-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); /* 背景改淡，配合模糊 */
    backdrop-filter: blur(8px); /* 毛玻璃背景 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.shop-content {
    background: rgba(30, 39, 46, 0.95); /* 深蓝半透明 */
    padding: 30px;
    border-radius: 16px;
    width: 700px;
    max-width: 95%;
    text-align: center;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    max-height: 85vh;
    overflow-y: auto;
}

/* 商店标题样式 */
.shop-content h2 {
    font-size: 32px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
}

#shop-gold {
    font-size: 20px;
    color: #f1c40f;
    margin-bottom: 25px;
    text-shadow: 0 0 5px rgba(241, 196, 15, 0.5);
}

/* 自定义滚动条 */
.shop-content::-webkit-scrollbar {
    width: 6px;
}

.shop-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.shop-content::-webkit-scrollbar-thumb {
    background: #576574;
    border-radius: 3px;
}

.shop-content::-webkit-scrollbar-thumb:hover {
    background: #f1c40f;
}

.shop-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    color: #8395a7;
    font-size: 18px;
    padding: 10px 30px;
    cursor: pointer;
    position: relative;
    transition: color 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 3px;
    background: #f1c40f;
    transform: scaleX(0);
    transition: transform 0.3s ease;
    box-shadow: 0 0 10px #f1c40f;
}

.tab-btn.active {
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.shop-section {
    display: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
}

.shop-section:not(.active) {
    display: none;
}

.shop-section.active {
    display: flex;
}

.shop-item {
    background: linear-gradient(145deg, #2d3436, #1e272e);
    padding: 0; /* padding 移到内部元素 */
    border-radius: 12px;
    width: 180px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

/* Hover 光效 */
.shop-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(52, 152, 219, 0.4);
    border-color: rgba(52, 152, 219, 0.6);
}

/* 上半部分：图标展示区 */
.item-icon {
    width: 100%;
    height: 100px;
    background: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0) 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    padding-top: 15px;
}

.item-icon svg {
    width: 56px;
    height: 56px;
    fill: currentColor;
    color: #bdc3c7;
    transition: all 0.3s;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
}

.shop-item:hover .item-icon svg {
    color: #fff;
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

/* 中间部分：信息区 */
.item-info {
    padding: 10px 15px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.item-name {
    font-size: 15px;
    font-weight: bold;
    color: #ecf0f1;
    margin-bottom: 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.item-desc {
    font-size: 12px;
    color: #95a5a6;
    margin-bottom: 0;
    height: 32px;
    line-height: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 下半部分：价格按钮 */
.item-price {
    margin: 10px 0 15px 0;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 18px;
    border-radius: 20px;
    color: #f1c40f;
    font-weight: bold;
    font-size: 14px;
    border: 1px solid rgba(241, 196, 15, 0.3);
    transition: all 0.2s;
}

.shop-item:hover .item-price {
    background: #f1c40f;
    color: #2c3e50;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.4);
}

.revive-btn {
    margin-top: 25px;
    padding: 12px 40px;
    font-size: 20px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.revive-btn:hover {
    background: #2ecc71;
}

/* 游戏结束模态框 */
#game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200; /* 比商店更高 */
}

.game-over-content {
    text-align: center;
    color: white;
    animation: fadeIn 0.5s ease-out;
}

#game-over-title {
    font-size: 80px;
    margin-bottom: 50px;
    text-shadow: 0 0 20px currentColor;
    font-weight: 900;
    letter-spacing: 5px;
}

.restart-btn {
    padding: 20px 60px;
    font-size: 32px;
    background: linear-gradient(to bottom, #f1c40f, #f39c12);
    color: #2c3e50;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(241, 196, 15, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.restart-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(241, 196, 15, 0.6);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* 游戏内通知系统 */
#notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}

.notification-toast {
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    animation: toastSlideIn 0.3s ease-out forwards, toastFadeOut 0.5s ease-in 2.5s forwards;
    border-left: 5px solid #bdc3c7;
    min-width: 200px;
    text-align: center;
}

.notification-toast.success {
    border-left-color: #2ecc71;
    background: rgba(39, 174, 96, 0.9);
}

.notification-toast.error {
    border-left-color: #e74c3c;
    background: rgba(192, 57, 43, 0.9);
}

.notification-toast.info {
    border-left-color: #3498db;
    background: rgba(41, 128, 185, 0.9);
}

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

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

/* =========================================
   NEW & IMPROVED STYLES (Menu, Lobby, Weapon Select)
   ========================================= */

/* Main Menu & Lobby Background */
#main-menu, #multiplayer-lobby, #login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Deep gaming gradient */
    background: radial-gradient(circle at center, #1a2a6c, #b21f1f, #fdbb2d); 
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364); /* Alternative cleaner look */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
    font-family: 'Microsoft YaHei', sans-serif;
    overflow: hidden;
}

/* Animated Background Effect Overlay */
#main-menu::before, #multiplayer-lobby::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 60%);
    animation: bgRotate 20s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes bgRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Menu Title */
.menu-title {
    font-size: 72px;
    margin-bottom: 60px;
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 5px;
    color: #fff;
    text-shadow: 
        0 0 10px #00d2ff,
        0 0 20px #00d2ff,
        0 0 40px #00d2ff,
        0 0 80px #00d2ff;
    animation: titlePulse 2s ease-in-out infinite alternate;
}

@keyframes titlePulse {
    from { text-shadow: 0 0 10px #00d2ff, 0 0 20px #00d2ff; }
    to { text-shadow: 0 0 20px #00d2ff, 0 0 40px #00d2ff, 0 0 60px #00d2ff; }
}

/* Menu Buttons */
.menu-btn {
    width: 300px;
    padding: 20px;
    margin: 15px;
    font-size: 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #00d2ff;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.4);
    transform: translateY(-2px) scale(1.02);
    color: #fff;
}

.menu-btn:hover::before {
    left: 100%;
}

/* Lobby Styles */
.lobby-panel {
    background: rgba(16, 20, 24, 0.8);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    min-width: 450px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    backdrop-filter: blur(20px);
}

.lobby-input {
    padding: 15px;
    font-size: 20px;
    border-radius: 0;
    border: none;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    width: 80%;
    margin-bottom: 30px;
    text-align: center;
    background: transparent;
    color: white;
    outline: none;
    transition: all 0.3s;
}

.lobby-input:focus {
    border-bottom-color: #00d2ff;
    box-shadow: 0 5px 10px -5px rgba(0, 210, 255, 0.3);
}

/* Improved Weapon Selection Styles */
.weapon-select-container {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-top: 40px;
    perspective: 1000px;
}

.weapon-card {
    background: linear-gradient(160deg, #2c3e50, #000);
    border-radius: 20px;
    padding: 40px 20px;
    width: 280px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.weapon-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 210, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.weapon-card:hover {
    transform: translateY(-15px) rotateX(5deg);
    border-color: #00d2ff;
    box-shadow: 0 20px 40px rgba(0, 210, 255, 0.3);
}

.weapon-card:hover::after {
    opacity: 1;
}

.weapon-card-icon svg {
    width: 100px;
    height: 100px;
    fill: #ecf0f1;
    margin-bottom: 25px;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5));
    transition: all 0.3s;
}

.weapon-card:hover .weapon-card-icon svg {
    transform: scale(1.1);
    fill: #00d2ff;
    filter: drop-shadow(0 0 15px #00d2ff);
}

.weapon-card h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 26px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.weapon-card p {
    color: #bdc3c7;
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.5;
}

.weapon-stat {
    color: #ecf0f1;
    margin: 8px 0;
    font-size: 14px;
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Modal Animation */
#weapon-select-modal .shop-content {
    animation: modalPopUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPopUp {
    from { opacity: 0; transform: scale(0.8) translateY(50px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Pre-Game Selection Highlight */
.selected-item {
    border-color: #f1c40f !important;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6) !important;
    transform: scale(1.05);
    background: linear-gradient(145deg, #34495e, #2c3e50) !important;
}

.selected-item .item-price {
    background: #f1c40f !important;
    color: #2c3e50 !important;
    content: "已选择" !important;
}
