* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0d12;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #e8e8e8;
}

.hidden { display: none !important; }

#game-container {
    position: fixed;
    inset: 0;
    z-index: 0;
}
#game-container canvas { display: block; }

/* ---------- 加载界面 ---------- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: radial-gradient(ellipse at center, #16202b 0%, #080b10 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.loader { text-align: center; }
.loader h1 {
    font-size: 44px;
    letter-spacing: 12px;
    color: #c8a24a;
    text-shadow: 0 0 30px rgba(200,162,74,.5);
    margin-bottom: 30px;
}
.progress-bar {
    width: 340px;
    height: 8px;
    background: #1a2330;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 14px;
}
#load-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #7a5a1e, #c8a24a);
    border-radius: 4px;
    transition: width .3s;
}
#load-text { font-size: 13px; color: #7a8494; letter-spacing: 2px; }

/* ---------- HUD ---------- */
#hud {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}
#hud * { pointer-events: none; }

/* 玩家面板 */
#player-panel {
    position: absolute;
    top: 18px;
    left: 18px;
    width: 252px;
    padding: 14px 16px;
    background: linear-gradient(160deg, rgba(18,26,40,.85), rgba(10,14,22,.75));
    border: 1px solid rgba(200,162,74,.35);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 30px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.06);
}
.panel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.lvl-badge {
    background: linear-gradient(135deg,#7a5a1e,#c8a24a,#f0d27a);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    padding: 4px 11px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 0 12px rgba(200,162,74,.5), inset 0 1px 0 rgba(255,255,255,.3);
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.xp-bar-wrap {
    flex: 1; height: 16px; background: #161d2c; border-radius: 8px; overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,.05);
}
.xp-fill {
    width: 0%; height: 100%;
    background: linear-gradient(90deg,#8a6a2a,#d4b25e,#ffd76a);
    border-radius: 8px;
    transition: width .25s ease;
    box-shadow: 0 0 10px rgba(212,178,94,.5);
}
.xp-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 800; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.9);
    letter-spacing: 1px;
}
.stat-block { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hp-icon { color: #ff5566; font-size: 16px; text-shadow: 0 0 8px rgba(255,60,80,.6); }
.bar-wrap {
    flex: 1; height: 18px; background: #161d2c; border-radius: 9px; overflow: hidden;
    position: relative;
    border: 1px solid rgba(255,255,255,.05);
}
.hp-bar {
    height: 100%; border-radius: 9px;
    transition: width .2s ease;
}
.hp-bar {
    background: linear-gradient(90deg,#8f1f24,#e5484d,#ff7080);
    box-shadow: 0 0 8px rgba(229,72,77,.4);
}
.bar-wrap span {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.8);
}

/* 统计面板 */
#stats-panel {
    position: absolute;
    top: 18px;
    right: 18px;
    padding: 14px 18px;
    background: linear-gradient(160deg, rgba(18,26,40,.85), rgba(10,14,22,.75));
    border: 1px solid rgba(200,162,74,.35);
    border-radius: 12px;
    text-align: right;
    font-size: 13px;
    line-height: 2.1;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 30px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.06);
}
#stats-panel b {
    color: #c8a24a; margin-left: 3px; font-size: 14px;
    text-shadow: 0 0 6px rgba(200,162,74,.3);
}
.k-icon{color:#ff6b6b;text-shadow:0 0 6px rgba(255,80,80,.5)}
.g-icon{color:#ffd76a;text-shadow:0 0 6px rgba(255,215,106,.5)}
.w-icon{color:#7fd4ff;text-shadow:0 0 6px rgba(127,212,255,.5)}

/* 技能栏 */
#skill-bar {
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    pointer-events: auto;
    padding: 8px 12px;
    background: rgba(8,12,18,.5);
    border: 1px solid rgba(200,162,74,.2);
    border-radius: 14px;
    backdrop-filter: blur(4px);
}
/* 提示 */
#tip-bar {
    position: absolute;
    bottom: 104px; left: 50%;
    transform: translateX(-50%);
    font-size: 11px; color: rgba(255,255,255,.45);
    letter-spacing: 1px;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0,0,0,.8);
}

/* 准星 */
#crosshair {
    position: absolute; top: 50%; left: 50%;
    width: 6px; height: 6px;
    transform: translate(-50%,-50%);
    border-radius: 50%;
    background: rgba(255,255,255,.85);
    box-shadow: 0 0 6px rgba(200,162,74,.8);
}

/* 伤害数字层 */
#damage-layer {
    position: absolute; inset: 0; overflow: hidden;
}
.dmg-num {
    position: absolute;
    transform: translate(-50%,-50%);
    font-weight: 800;
    font-family: 'Impact','Arial Black','Microsoft YaHei',sans-serif;
    -webkit-text-stroke: 1px rgba(0,0,0,.7);
    text-shadow: 0 2px 4px rgba(0,0,0,.9), 0 0 10px currentColor;
    animation: floatUp 0.95s cubic-bezier(.2,.7,.3,1) forwards;
    pointer-events: none;
}
@keyframes floatUp {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); }
    15% { opacity: 1; transform: translate(-50%,-60%) scale(1.15); }
    40% { transform: translate(-50%,-95%) scale(1); }
    100% { opacity: 0; transform: translate(-50%,-200%) scale(.85); }
}

/* 波次公告 */
#wave-banner {
    position: absolute; top: 22%; left: 50%;
    transform: translateX(-50%);
    font-size: 36px; font-weight: 800;
    letter-spacing: 8px;
    font-family: 'Impact','Arial Black','Microsoft YaHei',sans-serif;
    color: #f0d27a;
    -webkit-text-stroke: 1.5px rgba(0,0,0,.5);
    text-shadow: 0 0 30px rgba(255,215,106,.8), 0 4px 10px rgba(0,0,0,.8);
    opacity: 0;
    pointer-events: none;
}
#wave-banner.show { animation: bannerIn 2.4s ease-out forwards; }
@keyframes bannerIn {
    0% { opacity: 0; transform: translateX(-50%) scale(.6); }
    20% { opacity: 1; transform: translateX(-50%) scale(1.05); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* ---------- 开始界面 ---------- */
#start-screen {
    position: fixed; inset: 0; z-index: 50;
    background: radial-gradient(ellipse at center, rgba(10,14,20,.55) 0%, rgba(4,6,10,.75) 100%);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(1px);
}
.start-box {
    text-align: center;
    padding: 40px 60px;
    background: rgba(10,14,20,.6);
    border: 1px solid rgba(200,162,74,.3);
    border-radius: 14px;
    box-shadow: 0 0 60px rgba(0,0,0,.6);
}
.start-box h1 {
    font-size: 52px; letter-spacing: 10px;
    color: #c8a24a;
    text-shadow: 0 0 40px rgba(200,162,74,.5);
}
.subtitle { color: #9aa4b2; letter-spacing: 4px; margin: 8px 0 24px; font-size: 14px; }
#char-preview { height: 130px; display: flex; align-items: center; justify-content: center; }
.controls {
    list-style: none; margin: 18px 0 30px;
    text-align: left; font-size: 14px; line-height: 2.2; color: #b8c0cc;
}
.controls b {
    color: #f0d27a; display: inline-block; min-width: 100px;
    text-shadow: 0 0 6px rgba(255,215,106,.3);
}
#start-btn {
    pointer-events: auto;
    padding: 15px 56px;
    font-size: 19px; letter-spacing: 4px;
    background: linear-gradient(135deg,#7a5a1e,#c8a24a,#f0d27a);
    color: #fff; border: none; border-radius: 30px;
    cursor: pointer;
    font-weight: 800;
    box-shadow: 0 6px 26px rgba(200,162,74,.4), inset 0 1px 0 rgba(255,255,255,.3);
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
    transition: transform .12s, box-shadow .25s, filter .2s;
}
#start-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 36px rgba(200,162,74,.55); filter: brightness(1.08); }
#start-btn:active { transform: translateY(0) scale(.98); }

/* ---------- 死亡界面 ---------- */
#death-screen {
    position: fixed; inset: 0; z-index: 60;
    background: radial-gradient(ellipse at center, rgba(80,10,16,.8), rgba(0,0,0,.9));
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 20px;
}
#death-screen h1 {
    font-size: 52px; letter-spacing: 10px; color: #ff5566;
    font-family: 'Impact','Arial Black','Microsoft YaHei',sans-serif;
    -webkit-text-stroke: 1.5px rgba(0,0,0,.5);
    text-shadow: 0 0 50px rgba(255,60,80,.7), 0 4px 12px rgba(0,0,0,.8);
}
#death-stats {
    font-size: 16px; color: #d0d6de; letter-spacing: 1px;
    background: rgba(0,0,0,.4);
    padding: 12px 28px;
    border-radius: 10px;
    border: 1px solid rgba(255,80,100,.2);
}
#respawn-btn, #resume-btn {
    pointer-events: auto;
    padding: 14px 48px; font-size: 17px; letter-spacing: 3px;
    background: linear-gradient(135deg,#7a5a1e,#c8a24a,#f0d27a);
    color: #fff; border: none; border-radius: 30px; cursor: pointer; font-weight: 800;
    box-shadow: 0 6px 22px rgba(200,162,74,.35), inset 0 1px 0 rgba(255,255,255,.3);
    transition: transform .12s, box-shadow .25s, filter .2s;
}
#respawn-btn:hover, #resume-btn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 10px 30px rgba(200,162,74,.5); }

/* 屏幕震动 */
@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 3px); }
    40% { transform: translate(6px, -3px); }
    60% { transform: translate(-4px, -2px); }
    80% { transform: translate(4px, 2px); }
}

/* ---------- 暂停界面 ---------- */
#pause-screen {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(5,8,12,.75);
    backdrop-filter: blur(3px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 24px;
}
#pause-screen h1 { font-size: 42px; letter-spacing: 10px; color: #c8a24a; }

/* ---------- 升级技能选择面板 ---------- */
#levelup-screen {
    position: fixed; inset: 0; z-index: 58;
    background: rgba(5,8,14,.78);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.levelup-box {
    text-align: center;
    padding: 40px 48px;
    background: linear-gradient(170deg, rgba(20,28,42,.95), rgba(10,16,26,.9));
    border: 2px solid rgba(200,162,74,.55);
    border-radius: 20px;
    box-shadow: 0 0 70px rgba(200,162,74,.25), inset 0 1px 0 rgba(255,255,255,.08);
    max-width: 780px;
    width: 90%;
}
#levelup-title {
    color: #ffd76a;
    letter-spacing: 5px;
    font-size: 26px;
    margin-bottom: 30px;
    text-shadow: 0 0 24px rgba(255,215,106,.5);
}
#levelup-options {
    display: flex;
    gap: 18px;
    justify-content: center;
    flex-wrap: wrap;
}
.levelup-option {
    pointer-events: auto;
    cursor: pointer;
    flex: 1;
    min-width: 190px;
    max-width: 240px;
    padding: 26px 20px;
    background: linear-gradient(170deg, rgba(30,42,60,.9), rgba(16,24,38,.9));
    border: 2px solid rgba(200,162,74,.4);
    border-radius: 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform .15s, border-color .2s, box-shadow .2s;
}
.levelup-option::before {
    content: '';
    position: absolute; top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 50% 0%, rgba(255,215,106,.12), transparent 55%);
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}
.levelup-option:hover {
    transform: translateY(-6px);
    border-color: #f0d27a;
    box-shadow: 0 10px 36px rgba(200,162,74,.35);
}
.levelup-option:hover::before { opacity: 1; }
.lu-icon {
    font-size: 46px; display: block; margin-bottom: 12px;
    filter: drop-shadow(0 0 10px rgba(255,215,106,.4));
}
.lu-name { font-size: 19px; font-weight: 800; color: #fff; letter-spacing: 2px; margin-bottom: 8px; }
.lu-desc { font-size: 12px; color: #9aa4b2; line-height: 1.7; min-height: 44px; }
.lu-level {
    display: inline-block;
    margin-top: 12px;
    font-size: 12px; font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(200,162,74,.18);
    color: #f0d27a;
    letter-spacing: 1px;
    box-shadow: inset 0 0 0 1px rgba(255,215,106,.15);
}
.lu-new { color: #66ff88; background: rgba(102,255,136,.12); }
.levelup-hint { margin-top: 26px; font-size: 12px; color: #7a8494; letter-spacing: 1px; }

/* 已获得技能的技能栏 */
.skill-slot {
    width: 58px; height: 58px;
    background: radial-gradient(circle at 30% 25%, rgba(60,80,130,.35), rgba(12,16,24,.85));
    border: 2px solid rgba(200,162,74,.45);
    border-radius: 12px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    position: relative;
    gap: 1px;
    box-shadow: 0 4px 14px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08);
    transition: transform .12s, box-shadow .2s;
}
.skill-slot:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(200,162,74,.25);
}
.skill-slot .skill-icon { font-size: 26px; filter: drop-shadow(0 0 6px rgba(255,215,106,.4)); }
.skill-slot .skill-lv {
    font-size: 10px; font-weight: 800; color: #ffd76a;
    position: absolute; top: 3px; right: 5px;
    background: rgba(0,0,0,.5);
    padding: 1px 4px;
    border-radius: 6px;
    text-shadow: 0 0 4px rgba(255,215,106,.5);
}
.skill-slot .skill-cd {
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.7), rgba(0,0,0,.55));
    color: #fff; font-weight: 800; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    text-shadow: 0 0 8px rgba(255,255,255,.4);
}
.potion-slot { border-color: rgba(232,80,110,.5); }
.potion-slot:hover { border-color: #e8506e; }
.drop-slot { border-color: rgba(255,85,102,.6); }
.drop-slot:hover { border-color: #ff5566; }
.potion-count {
    position: absolute; bottom: 3px; right: 6px;
    font-size: 11px; color: #ff8090; font-weight: 800;
    background: rgba(0,0,0,.5);
    padding: 1px 4px;
    border-radius: 6px;
}
.potion-icon { font-size: 26px; }
