Загрузка данных


<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>🎃 MusorCase — Halloween Edition 💎</title>
<style>
*{margin:0;padding:0;box-sizing:border-box;font-family:Arial,sans-serif}
body{background:linear-gradient(135deg,#0a0a0f 0%,#1a0a1f 50%,#0f0a1a 100%);color:#fff;min-height:100vh;padding:15px}
body::before{content:'';position:fixed;top:0;left:0;width:100%;height:100%;background:radial-gradient(circle at 20% 30%,rgba(249,115,22,.08),transparent 50%),radial-gradient(circle at 80% 70%,rgba(168,85,247,.08),transparent 50%);pointer-events:none;z-index:0}
.container{max-width:1200px;margin:0 auto;position:relative;z-index:1}
header{display:flex;justify-content:space-between;align-items:center;background:rgba(0,0,0,.6);padding:12px;border-radius:10px;margin-bottom:10px;flex-wrap:wrap;gap:8px;border:1px solid #f97316;box-shadow:0 0 20px rgba(249,115,22,.2)}
h1{font-size:20px;color:#f97316;text-shadow:0 0 10px rgba(249,115,22,.5)}
.h1-sub{font-size:10px;color:#a78bfa;display:block;font-style:italic}
.balance{background:linear-gradient(135deg,#2d5016,#1a3a0a);padding:6px 12px;border-radius:6px;font-weight:bold;font-size:14px;border:1px solid #4a8020}
.balance span{color:#7fff00}
.diamonds{background:linear-gradient(135deg,#1e40af,#312e81);padding:6px 12px;border-radius:6px;font-weight:bold;font-size:14px;border:1px solid #60a5fa}
.diamonds span{color:#60a5fa}
button{cursor:pointer;border:none;font-weight:bold}
.topup-btn{background:#10b981;color:#fff;padding:7px 12px;border-radius:6px;font-size:12px}
.sound-btn{background:#6b7280;color:#fff;padding:7px 12px;border-radius:6px;font-size:14px}
.halloween-ticker{background:linear-gradient(90deg,#f97316,#7c2d12,#a855f7,#f97316);padding:8px 0;margin-bottom:12px;border-radius:8px;overflow:hidden;white-space:nowrap;font-weight:bold;font-size:13px;border:1px solid #f97316}
.halloween-ticker-inner{display:inline-block;animation:ticker 45s linear infinite;padding-left:100%}
@keyframes ticker{0%{transform:translateX(0)}100%{transform:translateX(-100%)}}
.tabs{display:flex;gap:4px;margin-bottom:12px;flex-wrap:wrap;background:rgba(0,0,0,.6);padding:6px;border-radius:8px;border:1px solid #7c2d12}
.tab{flex:1;min-width:70px;padding:7px 3px;background:rgba(255,255,255,.05);border-radius:5px;color:#fff;font-size:10px;text-align:center}
.tab.active{background:linear-gradient(135deg,rgba(249,115,22,.3),rgba(168,85,247,.3));border:1px solid #f97316;color:#f97316;box-shadow:0 0 10px rgba(249,115,22,.3)}
.section{display:none}.section.active{display:block}
.panel{background:rgba(0,0,0,.5);padding:12px;border-radius:8px;margin-bottom:10px;border:1px solid #7c2d12}
h2.title{color:#f97316;margin-bottom:10px;text-align:center;font-size:16px;text-shadow:0 0 10px rgba(249,115,22,.3)}
.cases-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px}
.case-card{background:rgba(255,255,255,.05);border:2px solid;border-radius:8px;padding:8px;text-align:center;cursor:pointer;position:relative;transition:.2s}
.case-card:hover{transform:translateY(-3px);box-shadow:0 5px 15px rgba(0,0,0,.5)}
.case-card.selected{box-shadow:0 0 15px currentColor}
.case-card img{width:55px;height:55px}
.case-card .name{font-weight:bold;font-size:11px;margin:4px 0}
.case-card .price{color:#7fff00;font-size:13px;font-weight:bold}
.case-card .price.diamond{color:#60a5fa}
.case-card .chance{font-size:9px;color:#f97316;margin-top:2px}
.case-card .view-btn{position:absolute;top:2px;right:2px;background:rgba(0,0,0,.8);border:1px solid #f97316;color:#f97316;padding:2px 4px;border-radius:3px;font-size:9px}
.case-card .limited-badge{position:absolute;top:2px;left:2px;background:#ef4444;color:#fff;padding:1px 4px;border-radius:3px;font-size:8px;font-weight:bold;animation:pulse 2s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.6}}
.case-basic{border-color:#718096}.case-standard{border-color:#3b82f6}.case-premium{border-color:#8b5cf6}
.case-legendary{border-color:#ef4444}.case-elite{border-color:#fbbf24}.case-gloves{border-color:#14b8a6}
.case-knife{border-color:#f59e0b}.case-halloween{border-color:#f97316;background:linear-gradient(135deg,rgba(249,115,22,.15),rgba(124,45,18,.15))}
.case-cursed{border-color:#a855f7;background:linear-gradient(135deg,rgba(168,85,247,.15),rgba(88,28,135,.15))}
.case-blood{border-color:#dc2626;background:linear-gradient(135deg,rgba(220,38,38,.15),rgba(127,29,29,.15))}
.speed-switcher{display:flex;justify-content:center;gap:5px;margin:8px 0}
.speed-btn{background:rgba(255,255,255,.05);color:#fff;padding:5px 10px;border-radius:5px;font-size:11px;border:1px solid #374151}
.speed-btn.active{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;border-color:#f97316}
.open-controls{display:flex;justify-content:center;gap:6px;flex-wrap:wrap}
.open-btn{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:9px 18px;border-radius:6px;font-size:13px;min-width:80px}
.open-btn:disabled{opacity:.5}
.open-btn.x5{background:linear-gradient(135deg,#8b5cf6,#5b21b6);color:#fff}
.open-btn.x10{background:linear-gradient(135deg,#ef4444,#991b1b);color:#fff}
.open-btn .sub{display:block;font-size:9px;opacity:.8}
.roulette-container{position:relative;width:100%;height:130px;overflow:hidden;background:rgba(0,0,0,.6);border-radius:6px;margin:12px 0;display:none;border:1px solid #f97316}
.roulette-pointer{position:absolute;top:0;left:50%;transform:translateX(-50%);width:3px;height:100%;background:#f97316;z-index:10;box-shadow:0 0 10px #f97316}
.roulette-track{display:flex;position:absolute;top:5px;left:0}
.roulette-item{width:110px;height:110px;margin:0 3px;border-radius:5px;display:flex;flex-direction:column;align-items:center;justify-content:center;flex-shrink:0;border:2px solid;position:relative}
.roulette-item img{width:55px;height:55px}
.roulette-item .iname{font-size:9px;margin-top:2px;text-align:center;padding:0 3px}
.roulette-item .wear-tag{position:absolute;top:2px;right:2px;font-size:7px;padding:1px 3px;border-radius:2px;background:rgba(0,0,0,.7);color:#fbbf24;font-weight:bold}
.rarity-common{background:linear-gradient(135deg,#4a5568,#2d3748);border-color:#718096}
.rarity-rare{background:linear-gradient(135deg,#2563eb,#1e40af);border-color:#3b82f6}
.rarity-epic{background:linear-gradient(135deg,#7c3aed,#5b21b6);border-color:#8b5cf6}
.rarity-legendary{background:linear-gradient(135deg,#dc2626,#991b1b);border-color:#ef4444}
.rarity-knife{background:linear-gradient(135deg,#fbbf24,#b45309);border-color:#fcd34d}
.rarity-gloves{background:linear-gradient(135deg,#14b8a6,#0f766e);border-color:#5eead4}
.rarity-halloween{background:linear-gradient(135deg,#f97316,#7c2d12);border-color:#fbbf24;box-shadow:0 0 15px rgba(249,115,22,.5)}
.multi-results{display:none}
.multi-stats{display:flex;justify-content:space-around;margin-bottom:10px;flex-wrap:wrap;gap:5px}
.stat-box{background:rgba(255,255,255,.05);padding:6px 10px;border-radius:5px;text-align:center;min-width:90px;border:1px solid #374151}
.stat-box .label{font-size:9px;color:#aaa}
.stat-box .value{font-size:14px;font-weight:bold}
.multi-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:6px}
.multi-item{background:rgba(255,255,255,.05);padding:6px;border-radius:5px;text-align:center;border:2px solid;opacity:0;animation:popIn .4s forwards}
.multi-item img{width:50px;height:50px}
.multi-item .name{font-size:9px;margin:2px 0;font-weight:bold}
.multi-item .price{color:#7fff00;font-size:10px;font-weight:bold}
.multi-item .wear{font-size:8px;color:#fbbf24;font-weight:bold}
@keyframes popIn{to{opacity:1;transform:scale(1)}}
.inv-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;flex-wrap:wrap;gap:6px}
.sell-all-btn{background:#ef4444;color:#fff;padding:5px 10px;border-radius:5px;font-size:10px}
.inventory-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:6px}
.inv-item{background:rgba(255,255,255,.05);padding:6px;border-radius:5px;text-align:center;border:2px solid;cursor:pointer;position:relative}
.inv-item img{width:50px;height:50px}
.inv-item .name{font-size:9px;margin:2px 0;font-weight:bold}
.inv-item .price{color:#7fff00;font-size:10px;font-weight:bold}
.inv-item .wear-tag{position:absolute;top:2px;right:2px;font-size:7px;padding:1px 3px;border-radius:2px;background:rgba(0,0,0,.7);color:#fbbf24;font-weight:bold}
.inv-item .stattrak{position:absolute;top:2px;left:2px;font-size:7px;padding:1px 3px;border-radius:2px;background:#f97316;color:#fff;font-weight:bold}
.empty{text-align:center;color:#888;padding:15px;font-style:italic;grid-column:1/-1}
.wheel-wrapper,.upgrade-center{display:flex;flex-direction:column;align-items:center;gap:10px}
.wheel-info{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin-bottom:8px}
.wheel-info-box{background:rgba(255,255,255,.05);padding:6px 10px;border-radius:5px;text-align:center;border:1px solid;display:flex;align-items:center;gap:6px}
.wheel-info-box img{width:35px;height:35px}
.wheel-info-box.win{border-color:#f97316;color:#f97316}
.wheel-info-box.lose{border-color:#718096;color:#a0aec0}
.wheel-container{position:relative;width:260px;height:260px}
.wheel-pointer{position:absolute;top:-10px;left:50%;transform:translateX(-50%);width:0;height:0;border-left:10px solid transparent;border-right:10px solid transparent;border-top:18px solid #f97316;z-index:10;filter:drop-shadow(0 0 5px #f97316)}
#wheelCanvas,#upgradeCanvas{width:100%;height:100%;border-radius:50%}
#wheelCanvas{transition:transform 5s cubic-bezier(.17,.67,.21,.99)}
.wheel-center{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:40px;height:40px;background:radial-gradient(circle,#f97316,#7c2d12);border-radius:50%;border:2px solid #fbbf24;z-index:5}
.wheel-center img{width:22px;height:22px}
.wheel-btn{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:10px 30px;border-radius:6px;font-size:14px;box-shadow:0 0 15px rgba(249,115,22,.4)}
.wheel-btn:disabled{opacity:.5}
.wheel-result{font-size:18px;font-weight:bold;min-height:25px;text-align:center;margin-top:6px}
.wheel-result.win{color:#f97316}
.wheel-result.lose{color:#a0aec0}
.upgrade-layout{display:grid;grid-template-columns:1fr auto 1fr;gap:10px;align-items:start}
@media(max-width:800px){.upgrade-layout{grid-template-columns:1fr}}
.upgrade-panel{background:rgba(255,255,255,.03);border:1px solid #7c2d12;border-radius:6px;padding:8px}
.upgrade-panel h3{color:#f97316;margin-bottom:5px;text-align:center;font-size:12px}
.upgrade-items{display:grid;grid-template-columns:repeat(auto-fill,minmax(85px,1fr));gap:4px;max-height:300px;overflow-y:auto}
.upgrade-item{background:rgba(255,255,255,.05);padding:4px;border-radius:4px;text-align:center;border:2px solid;cursor:pointer;font-size:8px;position:relative}
.upgrade-item.selected{box-shadow:0 0 10px currentColor;background:rgba(249,115,22,.15)}
.upgrade-item img{width:40px;height:40px}
.upgrade-item .name{margin:2px 0;font-weight:bold}
.upgrade-item .price{color:#7fff00;font-weight:bold}
.upgrade-item .wear-tag{position:absolute;top:1px;right:1px;font-size:6px;padding:1px 2px;border-radius:2px;background:rgba(0,0,0,.7);color:#fbbf24}
.upgrade-circle{position:relative;width:170px;height:170px}
#upgradeCanvas{transition:transform 4s cubic-bezier(.17,.67,.21,.99)}
.upgrade-percent{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:24px;font-weight:bold;color:#fff;text-shadow:0 0 8px rgba(0,0,0,.8);z-index:5}
.upgrade-btn{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:8px 25px;border-radius:6px;font-size:14px;width:100%;max-width:180px}
.upgrade-btn:disabled{opacity:.5;background:#4b5563}
.upgrade-result{font-size:14px;font-weight:bold;min-height:20px;text-align:center}
.upgrade-result.win{color:#7fff00}
.upgrade-result.lose{color:#ef4444}
.trade-layout{display:grid;grid-template-columns:1fr 1fr;gap:10px}
@media(max-width:800px){.trade-layout{grid-template-columns:1fr}}
.trade-panel{background:rgba(255,255,255,.03);border:1px solid #7c2d12;border-radius:6px;padding:8px}
.trade-panel h3{color:#f97316;text-align:center;margin-bottom:6px;font-size:12px}
.trade-selected{box-shadow:0 0 12px #f97316 !important}
.bot-offers{display:grid;gap:6px}
.bot-offer{background:rgba(255,255,255,.06);border:2px solid;border-radius:6px;padding:8px;display:grid;grid-template-columns:auto 1fr auto;gap:6px;align-items:center}
.bot-offer img{width:50px;height:50px}
.bot-name{color:#f97316;font-weight:bold;font-size:11px}
.bot-comment{color:#aaa;font-size:9px;font-style:italic}
.bot-price{color:#7fff00;font-weight:bold;font-size:11px}
.trade-accept{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:5px 8px;border-radius:5px;font-size:10px}
.daily-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:5px;margin-bottom:10px}
.daily-day{background:rgba(255,255,255,.05);border:2px solid #374151;border-radius:6px;padding:6px 3px;text-align:center}
.daily-day.claimed{background:rgba(16,185,129,.2);border-color:#10b981}
.daily-day.today{background:rgba(249,115,22,.2);border-color:#f97316;animation:pulse 2s infinite}
.daily-day.locked{opacity:.4}
.daily-day .day-num{font-size:9px;color:#aaa}
.daily-day .day-reward{font-size:12px;font-weight:bold;color:#f97316}
.daily-day .day-reward.diamond{color:#60a5fa}
.bp-container{display:grid;grid-template-columns:1fr 1fr;gap:10px}
@media(max-width:800px){.bp-container{grid-template-columns:1fr}}
.bp-track{background:rgba(255,255,255,.03);border:1px solid #7c2d12;border-radius:6px;padding:8px}
.bp-track.premium{border-color:#f97316;background:linear-gradient(135deg,rgba(249,115,22,.1),rgba(124,45,18,.1))}
.bp-track h3{text-align:center;margin-bottom:6px;font-size:12px;color:#f97316}
.bp-levels{display:flex;flex-direction:column;gap:3px;max-height:300px;overflow-y:auto}
.bp-level{background:rgba(255,255,255,.05);border:1px solid #374151;border-radius:5px;padding:5px;display:flex;align-items:center;gap:5px;font-size:10px}
.bp-level.unlocked{border-color:#f97316;background:rgba(249,115,22,.1)}
.bp-level.claimed{opacity:.5}
.bp-level .lvl-num{font-weight:bold;color:#f97316;width:22px}
.bp-level .lvl-reward{flex:1}
.bp-level .claim-btn{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:2px 6px;border-radius:3px;font-size:9px}
.bp-quests{background:rgba(255,255,255,.03);border:1px solid #7c2d12;border-radius:6px;padding:8px;margin-top:10px}
.bp-quests h3{color:#f97316;text-align:center;margin-bottom:6px;font-size:12px}
.quest{background:rgba(255,255,255,.05);border:1px solid #374151;border-radius:5px;padding:6px;margin-bottom:5px}
.quest .q-name{font-weight:bold;font-size:11px}
.quest .q-progress{height:5px;background:rgba(0,0,0,.5);border-radius:3px;overflow:hidden;margin:3px 0}
.quest .q-progress-fill{height:100%;background:linear-gradient(90deg,#f97316,#fbbf24)}
.quest .q-info{display:flex;justify-content:space-between;font-size:9px;color:#aaa}
.quest .q-reward{color:#f97316;font-weight:bold}
.quest.completed{border-color:#f97316;background:rgba(249,115,22,.1)}
.profile-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:8px}
.profile-box{background:rgba(255,255,255,.06);border:1px solid #7c2d12;border-radius:8px;padding:10px;text-align:center}
.profile-box .label{color:#aaa;font-size:10px;margin-bottom:3px}
.profile-box .value{color:#f97316;font-size:16px;font-weight:bold}
.rank-badge{font-size:16px;font-weight:bold;color:#f97316;text-shadow:0 0 10px rgba(249,115,22,.5)}
.rank-progress{width:100%;height:12px;background:rgba(0,0,0,.5);border-radius:8px;overflow:hidden;margin-top:4px;border:1px solid #374151}
.rank-progress-fill{height:100%;background:linear-gradient(90deg,#f97316,#fbbf24);transition:.4s}
.profile-btn{margin-top:6px;background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:5px 10px;border-radius:5px;font-size:10px}
.avatar-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(60px,1fr));gap:6px;margin-top:6px}
.avatar-item{width:60px;height:60px;border:3px solid #374151;border-radius:50%;cursor:pointer;overflow:hidden;background:rgba(0,0,0,.3);margin:0 auto}
.avatar-item.selected{border-color:#f97316;box-shadow:0 0 12px #f97316}
.avatar-item img{width:100%;height:100%}
.games-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:8px;margin-bottom:10px}
.game-card{background:linear-gradient(135deg,rgba(249,115,22,.2),rgba(124,45,18,.2));border:2px solid #f97316;border-radius:8px;padding:12px;text-align:center;cursor:pointer}
.game-card .gicon{font-size:45px;margin-bottom:5px}
.game-card .gname{font-size:14px;font-weight:bold;color:#f97316;margin-bottom:2px}
.game-card .gdesc{font-size:10px;color:#ccc}
.game-area{display:none;flex-direction:column;align-items:center;gap:8px}
.game-area.active{display:flex}
.game-hud{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;width:100%}
.hud-box{background:rgba(255,255,255,.05);padding:4px 8px;border-radius:5px;font-size:11px;border:1px solid #374151}
.hud-box span{color:#f97316;font-weight:bold}
#gdCanvas,#pacmanCanvas,#crashCanvas{border:2px solid #f97316;border-radius:6px;max-width:100%}
#gdCanvas{background:linear-gradient(180deg,#1a0a1f,#0a0a0f)}
#pacmanCanvas{background:#000}
#crashCanvas{background:#0f172a}
.game-controls{display:flex;gap:5px;flex-wrap:wrap;justify-content:center}
.game-btn{background:linear-gradient(135deg,#f97316,#7c2d12);color:#fff;padding:6px 14px;border-radius:5px;font-size:12px}
.game-btn.back{background:#6b7280}
.game-btn.cashout{background:#10b981}
.game-hint{color:#aaa;font-size:10px;text-align:center;font-style:italic}
.game-over-screen{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:none;align-items:center;justify-content:center;flex-direction:column;gap:8px;border-radius:6px;z-index:20}
.game-over-screen.active{display:flex}
.game-over-screen h2{color:#ef4444;font-size:22px}
.game-over-screen .reward{color:#f97316;font-size:16px;font-weight:bold}
.game-over-screen .meme{color:#fbbf24;font-size:12px;font-style:italic}
.canvas-wrapper{position:relative}
.modal{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.9);display:none;align-items:center;justify-content:center;z-index:1500;padding:12px}
.modal.active{display:flex}
.modal-content{background:linear-gradient(135deg,#0a0a0f,#1a0a1f);border:2px solid #f97316;border-radius:10px;padding:15px;max-width:550px;width:100%;max-height:85vh;overflow-y:auto;box-shadow:0 0 30px rgba(249,115,22,.3)}
.modal-content h2{color:#f97316;margin-bottom:10px;text-align:center}
.modal-close{background:#ef4444;color:#fff;padding:5px 10px;border-radius:5px;float:right}
.drop-list{display:grid;gap:5px}
.drop-item{background:rgba(255,255,255,.05);border:2px solid;border-radius:5px;padding:6px;display:flex;align-items:center;gap:6px}
.drop-item img{width:40px;height:40px}
.drop-item .drop-info{flex:1}
.drop-item .drop-name{font-weight:bold;font-size:11px}
.drop-item .drop-price{color:#7fff00;font-size:10px}
.drop-item .drop-chance{color:#f97316;font-size:9px;font-weight:bold}
.notification{position:fixed;top:12px;right:12px;padding:8px 14px;border-radius:6px;background:rgba(0,0,0,.95);border:2px solid #f97316;color:#fff;font-weight:bold;z-index:1000;animation:slideIn .3s;max-width:280px;display:flex;align-items:center;gap:6px;font-size:11px;box-shadow:0 0 20px rgba(249,115,22,.3)}
.notification img{width:28px;height:28px}
.notification .meme{font-size:9px;color:#fbbf24;font-style:italic;margin-top:2px}
@keyframes slideIn{from{transform:translateX(400px);opacity:0}to{transform:translateX(0);opacity:1}}
.big-meme{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.9);display:flex;align-items:center;justify-content:center;z-index:2000;animation:memeFlash 3s forwards;pointer-events:none}
.big-meme .content{text-align:center;animation:memeZoom 3s forwards}
.big-meme .emoji{font-size:100px;filter:drop-shadow(0 0 30px #f97316)}
.big-meme .text{font-size:40px;font-weight:bold;color:#f97316;text-shadow:0 0 30px #f97316;margin-top:6px}
.big-meme .subtext{font-size:16px;color:#fff;margin-top:5px;font-style:italic}
@keyframes memeFlash{0%{opacity:0}10%{opacity:1}80%{opacity:1}100%{opacity:0}}
@keyframes memeZoom{0%{transform:scale(0) rotate(-180deg)}30%{transform:scale(1.2) rotate(10deg)}50%{transform:scale(1) rotate(0deg)}100%{transform:scale(1) rotate(0deg)}}
</style>
</head>
<body>
<div class="container">

<div class="halloween-ticker">
<div class="halloween-ticker-inner">
🎃 HALLOWEEN UPDATE 2026 🎃 • 💎 АЛМАЗЫ — НОВАЯ ВАЛЮТА 💎 • 🕷️ ЛИМИТИРОВАННЫЕ СКИНЫ ТОЛЬКО ЗА АЛМАЗЫ 🕷️ • 🎃 ТЫКВА-КЕРАМБИТ УЖЕ В ИГРЕ 🎃 • 👻 ПРИЗРАК-БАБОЧКА — ЛЕГЕНДА 👻 • 🩸 КРОВАВЫЕ ПЕРЧАТКИ — РЕДКОСТЬ 🩸 • 🦇 SPOOKY SEASON 🦇 • 💀 F В ЧАТ ЕСЛИ НЕ ПОЛУЧИЛ НОЖ 💀 • 🎃 MUSORCASE — САМЫЙ СКАМНЫЙ ХЭЛЛОУИН 🎃 • 🕸️ ПАУТИНА УДАЧИ 🕸️ • 🔥 НОВЫЕ КЕЙСЫ: ПРОКЛЯТЫЙ, КРОВАВЫЙ, ТЫКВЕННЫЙ 🔥 • 🎃 TRICK OR TREAT? TREAT YOURSELF! 🎃
</div>
</div>

<header>
<h1>🎃 MusorCase<span class="h1-sub">Halloween Edition 💎</span></h1>
<div style="display:flex;gap:5px;align-items:center;flex-wrap:wrap">
<div class="balance">💰 <span id="balance">1000</span> ₽</div>
<div class="diamonds">💎 <span id="diamonds">0</span></div>
<button class="sound-btn" id="soundBtn" onclick="toggleSound()">🔊</button>
<button class="topup-btn" onclick="topup()">+500 ₽</button>
</div>
</header>

<div class="tabs">
<button class="tab active" onclick="switchTab('cases',this)">📦 Кейсы</button>
<button class="tab" onclick="switchTab('wheel',this)">🎡 Колесо</button>
<button class="tab" onclick="switchTab('upgrade',this)">⚡ Апгрейд</button>
<button class="tab" onclick="switchTab('trades',this)">🤖 Трейды</button>
<button class="tab" onclick="switchTab('battlepass',this)">🎫 БП</button>
<button class="tab" onclick="switchTab('daily',this)">🎁 Награды</button>
<button class="tab" onclick="switchTab('profile',this)">👤 Профиль</button>
<button class="tab" onclick="switchTab('games',this)">🎮 Игры</button>
</div>

<div class="section active" id="section-cases">
<div class="panel"><h2 class="title">🎃 Выбери кейс</h2><div class="cases-grid" id="casesGrid"></div></div>
<div class="panel">
<div id="currentCaseName" style="font-size:14px;color:#f97316;margin-bottom:8px;text-align:center">Выбран: Базовый кейс</div>
<div class="speed-switcher">
<button class="speed-btn" data-speed="fast" onclick="setSpeed('fast',this)">⚡ Быстро</button>
<button class="speed-btn active" data-speed="normal" onclick="setSpeed('normal',this)">🎯 Норм</button>
<button class="speed-btn" data-speed="slow" onclick="setSpeed('slow',this)">🐢 Медленно</button>
</div>
<div class="roulette-container" id="rouletteContainer"><div class="roulette-pointer"></div><div class="roulette-track" id="rouletteTrack"></div></div>
<div class="open-controls">
<button class="open-btn" id="openBtn1" onclick="openCase(1)">🔓 x1<span class="sub" id="price1">50 ₽</span></button>
<button class="open-btn x5" id="openBtn5" onclick="openCase(5)">🔓 x5<span class="sub" id="price5">250 ₽</span></button>
<button class="open-btn x10" id="openBtn10" onclick="openCase(10)">🔓 x10<span class="sub" id="price10">500 ₽</span></button>
</div>
</div>
<div class="panel multi-results" id="multiResults"><h2 class="title">🎁 Результаты</h2><div class="multi-stats" id="multiStats"></div><div class="multi-grid" id="multiGrid"></div></div>
<div class="panel"><div class="inv-header"><h2>🎒 Инвентарь (<span id="invCount">0</span>)</h2><button class="sell-all-btn" onclick="sellAll()">💸 Продать всё</button></div><div class="inventory-grid" id="inventoryGrid"><div class="empty">Инвентарь пуст</div></div></div>
</div>

<div class="section" id="section-wheel">
<div class="panel"><h2 class="title">🎃 Колесо Фортуны 30/70</h2>
<div class="wheel-info">
<div class="wheel-info-box win"><img id="wheelKnifeImg"><div><div>🗡️ НОЖ</div><div style="font-size:14px;font-weight:bold">+2500 ₽</div><div>30%</div></div></div>
<div class="wheel-info-box lose"><img id="wheelBulletImg"><div><div>🔩 ПАТРОН</div><div style="font-size:14px;font-weight:bold">0 ₽</div><div>70%</div></div></div>
</div>
<div class="wheel-wrapper">
<div class="wheel-container"><div class="wheel-pointer"></div><canvas id="wheelCanvas" width="260" height="260"></canvas><div class="wheel-center"><img id="wheelCenterImg"></div></div>
<button class="wheel-btn" id="wheelBtn" onclick="spinWheel()">🎃 КРУТИТЬ — 500 ₽</button>
<div class="wheel-result" id="wheelResult"></div>
</div>
</div>
</div>

<div class="section" id="section-upgrade">
<div class="panel"><h2 class="title">⚡ Апгрейдер</h2>
<div class="upgrade-layout">
<div class="upgrade-panel"><h3>📤 Твой скин</h3><div class="upgrade-items" id="upgradeSource"></div></div>
<div class="upgrade-center">
<div class="upgrade-circle"><div style="position:absolute;top:-6px;left:50%;transform:translateX(-50%);width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-top:14px solid #f97316;z-index:10"></div><canvas id="upgradeCanvas" width="170" height="170"></canvas><div class="upgrade-percent" id="upgradePercent">—%</div></div>
<button class="upgrade-btn" id="upgradeBtn" onclick="doUpgrade()" disabled>🚀 АПГРЕЙД</button>
<div class="upgrade-result" id="upgradeResult"></div>
</div>
<div class="upgrade-panel"><h3>📥 Целевой скин</h3><div class="upgrade-items" id="upgradeTarget"></div></div>
</div>
</div>
</div>

<div class="section" id="section-trades">
<div class="panel"><h2 class="title">🤖 Трейды с ботами</h2>
<div class="trade-layout">
<div class="trade-panel"><h3>📤 Твой скин</h3><div class="inventory-grid" id="tradeSource"></div></div>
<div class="trade-panel"><h3>📥 Боты</h3><div class="bot-offers" id="botOffers"><div class="empty">Выбери скин слева</div></div></div>
</div>
</div>
</div>

<div class="section" id="section-battlepass">
<div class="panel"><h2 class="title">🎃 Halloween Battle Pass</h2>
<div style="text-align:center;margin-bottom:10px">
<div style="font-size:14px;color:#f97316;font-weight:bold">Уровень: <span id="bpLevel">1</span> / 30</div>
<div style="color:#aaa;font-size:11px">Опыт: <span id="bpXP">0</span> / <span id="bpNextXP">100</span></div>
<div class="rank-progress" style="margin-top:5px"><div class="rank-progress-fill" id="bpProgressFill" style="width:0%"></div></div>
</div>
<div class="bp-container">
<div class="bp-track"><h3>🆓 Бесплатный</h3><div class="bp-levels" id="bpFreeTrack"></div></div>
<div class="bp-track premium"><h3>💎 Премиум</h3><div class="bp-levels" id="bpPremiumTrack"></div></div>
</div>
<div class="bp-quests"><h3>📋 Задания</h3><div id="bpQuests"></div></div>
</div>
</div>

<div class="section" id="section-daily">
<div class="panel"><h2 class="title">🎃 Ежедневные награды</h2>
<p style="text-align:center;color:#aaa;margin-bottom:10px;font-style:italic;font-size:11px">Заходи каждый день! Алмазы на 4 и 7 день!</p>
<div class="daily-grid" id="dailyGrid"></div>
<div style="text-align:center;margin-top:10px"><button class="profile-btn" onclick="claimDailyReward()" id="claimDailyBtn">🎁 Забрать</button></div>
</div>
</div>

<div class="section" id="section-profile">
<div class="panel"><h2 class="title">👤 Профиль</h2><div id="profileContent"></div></div>
</div>

<div class="section" id="section-games">
<div class="panel"><h2 class="title">🎃 Мини-Игры</h2>
<div class="games-grid" id="gamesGrid">
<div class="game-card" onclick="startGame('gd')"><div class="gicon">🎃</div><div class="gname">Geometry Dash</div><div class="gdesc">1₽ за 10 метров</div></div>
<div class="game-card" onclick="startGame('pacman')"><div class="gicon">👻</div><div class="gname">Pac-Man</div><div class="gdesc">1₽ за 10 очков</div></div>
<div class="game-card" onclick="startGame('crash')"><div class="gicon">📈</div><div class="gname">Crash</div><div class="gdesc">Забери до краха!</div></div>
</div>
<div class="game-area" id="gameArea-gd">
<div class="game-hud"><div class="hud-box">📏 <span id="gdDistance">0</span> м</div><div class="hud-box">💰 <span id="gdReward">0</span> ₽</div><div class="hud-box">🏆 <span id="gdRecord">0</span> м</div></div>
<div class="canvas-wrapper"><canvas id="gdCanvas" width="800" height="300"></canvas><div class="game-over-screen" id="gdGameOver"><h2>💀 GAME OVER</h2><div>Дистанция: <span id="gdFinalDist">0</span> м</div><div class="reward">+<span id="gdFinalReward">0</span> ₽</div><div class="meme" id="gdMeme"></div><button class="game-btn" onclick="restartGD()">🔄 Заново</button></div></div>
<div class="game-hint">⌨️ Пробел / Клик — прыжок</div>
<div class="game-controls"><button class="game-btn back" onclick="exitGame('gd')">← Выход</button></div>
</div>
<div class="game-area" id="gameArea-pacman">
<div class="game-hud"><div class="hud-box">👻 <span id="pmScore">0</span></div><div class="hud-box">💰 <span id="pmReward">0</span> ₽</div><div class="hud-box">❤️ <span id="pmLives">3</span></div></div>
<div class="canvas-wrapper"><canvas id="pacmanCanvas" width="448" height="496"></canvas><div class="game-over-screen" id="pmGameOver"><h2>💀 GAME OVER</h2><div>Очки: <span id="pmFinalScore">0</span></div><div class="reward">+<span id="pmFinalReward">0</span> ₽</div><div class="meme" id="pmMeme"></div><button class="game-btn" onclick="restartPacman()">🔄 Заново</button></div></div>
<div class="game-hint">⌨️ Стрелки / WASD / ЦЫФВ</div>
<div class="game-controls"><button class="game-btn back" onclick="exitGame('pacman')">← Выход</button></div>
</div>
<div class="game-area" id="gameArea-crash">
<div class="game-hud"><div class="hud-box">💵 Ставка: <input type="number" id="crashBet" value="100" min="10" style="width:55px;background:#1f2937;border:1px solid #7c2d12;color:#fff;padding:2px;border-radius:3px"> ₽</div><div class="hud-box">📈 <span id="crashMult">1.00</span>x</div><div class="hud-box">💰 <span id="crashWin">0</span> ₽</div></div>
<canvas id="crashCanvas" width="600" height="300"></canvas>
<div class="game-controls"><button class="game-btn" id="crashStartBtn" onclick="startCrash()">🚀 СТАРТ</button><button class="game-btn cashout" id="crashCashoutBtn" onclick="cashoutCrash()" disabled>💰 ЗАБРАТЬ</button><button class="game-btn back" onclick="exitGame('crash')">← Выход</button></div>
<div class="game-hint" id="crashStatus">Сделай ставку и нажми СТАРТ</div>
</div>
</div>
</div>

<div class="modal" id="dropModal"><div class="modal-content"><button class="modal-close" onclick="closeDropModal()">✕</button><h2 id="dropModalTitle">Содержимое</h2><div class="drop-list" id="dropList"></div></div></div>
</div>

<script>
// ============ ЗВУКИ ============
let audioCtx=null,soundEnabled=true;
function initAudio(){if(!audioCtx)audioCtx=new(window.AudioContext||window.webkitAudioContext)()}
function toggleSound(){soundEnabled=!soundEnabled;document.getElementById('soundBtn').textContent=soundEnabled?'🔊':'🔇'}
function playTone(f,d,t='sine',v=.2){if(!soundEnabled)return;initAudio();const o=audioCtx.createOscillator(),g=audioCtx.createGain();o.type=t;o.frequency.value=f;g.gain.setValueAtTime(v,audioCtx.currentTime);g.gain.exponentialRampToValueAtTime(.001,audioCtx.currentTime+d);o.connect(g);g.connect(audioCtx.destination);o.start();o.stop(audioCtx.currentTime+d)}
function playNoise(d,v=.1){if(!soundEnabled)return;initAudio();const b=audioCtx.createBuffer(1,audioCtx.sampleRate*d,audioCtx.sampleRate),dt=b.getChannelData(0);for(let i=0;i<dt.length;i++)dt[i]=(Math.random()*2-1)*(1-i/dt.length);const s=audioCtx.createBufferSource(),g=audioCtx.createGain();s.buffer=b;g.gain.value=v;s.connect(g);g.connect(audioCtx.destination);s.start()}
const SFX={
click:()=>playTone(800,.05,'square',.1),
open:()=>{playNoise(.3,.15);playTone(400,.2,'sawtooth',.1)},
tick:()=>playTone(1200,.02,'square',.05),
win:()=>{[523,659,784,1047].forEach((f,i)=>setTimeout(()=>playTone(f,.2,'triangle',.2),i*100))},
knife:()=>{[523,659,784,1047,1319].forEach((f,i)=>setTimeout(()=>playTone(f,.3,'triangle',.25),i*120))},
lose:()=>{[400,300,200,100].forEach((f,i)=>setTimeout(()=>playTone(f,.3,'sawtooth',.15),i*150))},
wheel:()=>playTone(200+Math.random()*100,.05,'square',.08),
upgrade:()=>{playTone(600,.1,'square',.15);setTimeout(()=>playTone(900,.2,'square',.15),100)},
jump:()=>{playTone(500,.1,'square',.1);setTimeout(()=>playTone(800,.1,'square',.08),50)},
coin:()=>{playTone(988,.05,'square',.1);setTimeout(()=>playTone(1319,.1,'square',.1),50)},
die:()=>{[400,300,200].forEach((f,i)=>setTimeout(()=>playTone(f,.2,'sawtooth',.2),i*100))},
powerup:()=>{[523,784,1047].forEach((f,i)=>setTimeout(()=>playTone(f,.15,'triangle',.2),i*80))},
crash:()=>playNoise(.5,.3),
crashTick:()=>playTone(400+Math.random()*200,.05,'square',.08),
diamond:()=>{[1047,1319,1568,2093].forEach((f,i)=>setTimeout(()=>playTone(f,.2,'triangle',.2),i*80))},
halloween:()=>{[220,277,330,220].forEach((f,i)=>setTimeout(()=>playTone(f,.4,'sawtooth',.15),i*200))}
};

const MEMES={
knifeWin:["ПОТРАЧЕНО 💀","ИЗИ КАТКА 🎃","ТЫ ЛЕГЕНДА 🗡️","+1 К АУРЕ","ЭТО БАЗА","СКУФ ОЦЕНИТ 🎃"],
legendaryWin:["ЛЕГЕНДА 🔥","ЭТО БАЗА","КРАСАВЧИК","ХЭЛЛОУИН УДАЧНЫЙ 🎃"],
epicWin:["ЭПИК МУВ 🎯","КРАСАВА","ИЗИ"],
rareWin:["РЕДКИЙ ДРОП ✨","НОРМАС","ПРИНЯТО"],
commonWin:["МУСОР 🗑️","ОЧЕРЕДНОЙ БОЛТ","F В ЧАТ","СКУФ-ДРОП","ТЫКВА ПУСТАЯ 🎃"],
lose:["F В ЧАТ 💀","СКАМ 100%","ТЫ ПРОСТО ЛОХ","ЗАЧЕМ ТЫ ЭТО КУПИЛ?","ХЭЛЛОУИН БЕЗ ПОДАРКОВ 🎃"],
upgradeWin:["ИЗИ АПГРЕЙД 🔥","БАЗА","КРАСАВЧИК","ВЕДЬМА ОДОБРЯЕТ 🧙"],
upgradeLose:["АПГРЕЙД? НЕ СЛЫШАЛ 💀","КАЗИНО В ПЛЮСЕ","НУ ТЫ И ЛОХ","ПРИЗРАК ЗАБРАЛ 🕷️"],
gdDeath:["ИЗИ ДЭТ 🎃","ТЫ НУБ","F В ЧАТ","ТЫКВА РАЗБИЛАСЬ 🎃"],
pmDeath:["ПАКМЕН МЁРТВ 💀","F В ЧАТ","ПРИЗРАКИ ПОБЕДИЛИ 👻"],
topup:["ДЕРЖИ КАРМАН 💸","БЕСПЛАТНЫЙ СЫР...","ЕЩЁ ПОЧКА ПРОДАЙ","КОНФЕТКА ИЛИ КОШЕЛЬКОМ? 🎃"],
halloween:["СЛАДКОСТЬ ИЛИ Гадость? 🎃","ХЭЛЛОУИН БАЗА 🕷️","ВЕДЬМИНСКИЙ ДРОП 🧙","СКУФ-ХЭЛЛОУИН 💀"]
};
function randMeme(a){return a[Math.floor(Math.random()*a.length)]}
function showBigMeme(e,t,s){const d=document.createElement('div');d.className='big-meme';d.innerHTML=`<div class="content"><div class="emoji">${e}</div><div class="text">${t}</div><div class="subtext">${s}</div></div>`;document.body.appendChild(d);setTimeout(()=>d.remove(),3000)}

// ============ СИСТЕМА ИЗНОСА (РЕАЛИЗМ) ============
const WEARS=[
{name:'FN',full:'Factory New',mult:1.5,color:'#10b981',chance:5},
{name:'MW',full:'Minimal Wear',mult:1.2,color:'#3b82f6',chance:15},
{name:'FT',full:'Field-Tested',mult:1.0,color:'#fbbf24',chance:40},
{name:'WW',full:'Well-Worn',mult:0.8,color:'#f97316',chance:25},
{name:'BS',full:'Battle-Scarred',mult:0.6,color:'#ef4444',chance:15}
];
function rollWear(){
const r=Math.random()*100;let c=0;
for(const w of WEARS){c+=w.chance;if(r<=c)return w}
return WEARS[2];
}
function rollStattrak(chance=10){return Math.random()*100<chance}

// ============ SVG ИКОНКИ ============
const ICONS={
karambit:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 75 Q15 50 30 35 Q50 20 75 25 L78 32 Q55 30 38 45 Q25 58 28 75 Z" fill="#d1d5db" stroke="#1f2937"/><circle cx="25" cy="72" r="8" fill="none" stroke="#78350f" stroke-width="4"/><path d="M20 75 L15 85 L30 82 Z" fill="#78350f"/></svg>`,
butterfly:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 50 L20 20 L25 15 L55 45 Z" fill="#d1d5db" stroke="#1f2937"/><path d="M50 50 L80 80 L75 85 L45 55 Z" fill="#d1d5db" stroke="#1f2937"/><path d="M50 50 L80 20 L85 25 L55 55 Z" fill="#4b5563"/><path d="M50 50 L20 80 L15 75 L45 45 Z" fill="#4b5563"/><circle cx="50" cy="50" r="5" fill="#b45309"/></svg>`,
m9bayonet:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M15 55 L75 45 L85 50 L75 55 L15 60 Z" fill="#d1d5db" stroke="#1f2937"/><rect x="10" y="52" width="20" height="10" fill="#78350f"/><rect x="5" y="50" width="8" height="14" fill="#1f2937" rx="2"/></svg>`,
talon:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 75 Q20 55 35 40 Q55 25 78 30 L80 38 Q58 35 42 48 Q30 60 32 75 Z" fill="#d1d5db" stroke="#1f2937"/><path d="M25 75 L20 82 L32 80 Z" fill="#78350f"/></svg>`,
flip:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 55 L78 50 L82 55 L78 60 L20 58 Z" fill="#d1d5db" stroke="#1f2937"/><rect x="12" y="52" width="15" height="8" fill="#78350f"/><circle cx="17" cy="56" r="1.5" fill="#fbbf24"/></svg>`,
skeleton:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 55 L75 48 L82 53 L75 58 L20 60 Z" fill="#1f2937" stroke="#6b7280"/><rect x="12" y="50" width="18" height="12" fill="#374151"/><circle cx="17" cy="56" r="2" fill="#ef4444"/><circle cx="25" cy="56" r="2" fill="#ef4444"/></svg>`,
fang:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 75 Q20 55 38 40 Q55 28 78 32 L80 40 Q60 38 45 50 Q32 62 35 75 Z" fill="#fbbf24" stroke="#78350f"/><path d="M25 75 L20 82 L35 80 Z" fill="#78350f"/></svg>`,
hunter:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 55 L70 48 L85 55 L70 62 L20 60 Z" fill="#d1d5db" stroke="#1f2937"/><rect x="10" y="50" width="18" height="14" fill="#78350f"/><rect x="5" y="48" width="8" height="18" fill="#1f2937" rx="2"/></svg>`,
navaja:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M30 55 L75 52 L78 56 L75 60 L30 58 Z" fill="#d1d5db" stroke="#1f2937"/><rect x="15" y="52" width="20" height="8" fill="#78350f"/><circle cx="25" cy="56" r="1.5" fill="#fbbf24"/></svg>`,
bayonet:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M15 55 L72 48 L85 55 L72 62 L15 60 Z" fill="#d1d5db" stroke="#1f2937"/><rect x="8" y="52" width="15" height="10" fill="#78350f"/></svg>`,
stiletto:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 75 L45 25 L50 25 L55 75 Z" fill="#e5e7eb" stroke="#1f2937"/><rect x="30" y="70" width="20" height="15" fill="#78350f" rx="2"/></svg>`,
ursus:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 55 L75 48 L82 55 L75 62 L20 60 Z" fill="#9ca3af" stroke="#1f2937"/><rect x="10" y="50" width="20" height="15" fill="#78350f" rx="2"/></svg>`,
// ХЭЛЛОУИН НОЖИ
pumpkin_karambit:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="pk1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fbbf24"/><stop offset=".5" stop-color="#f97316"/><stop offset="1" stop-color="#7c2d12"/></linearGradient></defs><path d="M20 75 Q15 50 30 35 Q50 20 75 25 L78 32 Q55 30 38 45 Q25 58 28 75 Z" fill="url(#pk1)" stroke="#451a03" stroke-width="1.5"/><circle cx="25" cy="72" r="8" fill="none" stroke="#1f2937" stroke-width="4"/><path d="M20 75 L15 85 L30 82 Z" fill="#1f2937"/><circle cx="45" cy="45" r="3" fill="#1f2937"/><circle cx="55" cy="40" r="3" fill="#1f2937"/><path d="M40 55 Q50 60 60 55" stroke="#1f2937" stroke-width="2" fill="none"/></svg>`,
ghost_butterfly:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="gb1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#e9d5ff"/><stop offset=".5" stop-color="#a855f7"/><stop offset="1" stop-color="#581c87"/></linearGradient></defs><path d="M50 50 L20 20 L25 15 L55 45 Z" fill="url(#gb1)" stroke="#1f2937" opacity=".9"/><path d="M50 50 L80 80 L75 85 L45 55 Z" fill="url(#gb1)" stroke="#1f2937" opacity=".9"/><path d="M50 50 L80 20 L85 25 L55 55 Z" fill="#6b21a8" opacity=".8"/><path d="M50 50 L20 80 L15 75 L45 45 Z" fill="#6b21a8" opacity=".8"/><circle cx="50" cy="50" r="5" fill="#fbbf24"/><circle cx="40" cy="35" r="2" fill="#1f2937"/><circle cx="60" cy="35" r="2" fill="#1f2937"/><path d="M45 45 Q50 50 55 45" stroke="#1f2937" stroke-width="1.5" fill="none"/></svg>`,
witch_blade:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="wb1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#a855f7"/><stop offset=".5" stop-color="#7c3aed"/><stop offset="1" stop-color="#1f2937"/></linearGradient></defs><path d="M15 55 L75 45 L85 50 L75 55 L15 60 Z" fill="url(#wb1)" stroke="#1f2937" stroke-width="1.5"/><path d="M20 50 L70 47" stroke="#fbbf24" stroke-width="1" opacity=".7"/><rect x="10" y="52" width="20" height="10" fill="#451a03" stroke="#1f2937"/><path d="M15 52 L25 52 L20 62 Z" fill="#f97316"/></svg>`,
blood_talon:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="bt1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fecaca"/><stop offset=".5" stop-color="#dc2626"/><stop offset="1" stop-color="#450a0a"/></linearGradient></defs><path d="M25 75 Q20 55 35 40 Q55 25 78 30 L80 38 Q58 35 42 48 Q30 60 32 75 Z" fill="url(#bt1)" stroke="#1f2937" stroke-width="1.5"/><path d="M25 75 L20 82 L32 80 Z" fill="#1f2937"/><circle cx="45" cy="50" r="2" fill="#7f1d1d"/><circle cx="55" cy="55" r="1.5" fill="#7f1d1d"/><circle cx="60" cy="45" r="1" fill="#7f1d1d"/></svg>`,
spider_flip:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="sf1" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#1f2937"/><stop offset=".5" stop-color="#374151"/><stop offset="1" stop-color="#000"/></linearGradient></defs><path d="M20 55 L78 50 L82 55 L78 60 L20 58 Z" fill="url(#sf1)" stroke="#f97316" stroke-width="1"/><circle cx="50" cy="55" r="6" fill="#1f2937" stroke="#f97316"/><circle cx="48" cy="53" r="1" fill="#f97316"/><circle cx="52" cy="53" r="1" fill="#f97316"/><path d="M45 55 L40 52 M55 55 L60 52 M45 57 L40 60 M55 57 L60 60" stroke="#f97316" stroke-width=".8"/></svg>`,
awp_dragon:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#dc2626" stroke="#78350f"/><rect x="80" y="45" width="12" height="14" fill="#78350f" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#fbbf24" stroke-width="1.5"/><circle cx="25" cy="52" r="3" fill="#60a5fa"/></svg>`,
ak_fire:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="70" height="8" fill="#ef4444" stroke="#78350f"/><path d="M75 48 L85 45 L85 59 L75 56 Z" fill="#78350f"/><rect x="25" y="56" width="15" height="10" fill="#78350f"/></svg>`,
m4a1_beast:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#7c3aed" stroke="#4c1d95"/><rect x="80" y="45" width="12" height="14" fill="#1f2937" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#a78bfa" stroke-width="1.5"/><circle cx="25" cy="52" r="3" fill="#fbbf24"/></svg>`,
awp_asimov:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#f3f4f6" stroke="#374151"/><rect x="80" y="45" width="12" height="14" fill="#1f2937" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#f3f4f6" stroke-width="1.5"/><circle cx="25" cy="52" r="3" fill="#ef4444"/></svg>`,
awp_gungnir:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#10b981" stroke="#065f46"/><rect x="80" y="45" width="12" height="14" fill="#78350f" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#10b981" stroke-width="1.5"/><circle cx="25" cy="52" r="3" fill="#fbbf24"/></svg>`,
ak_neon:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="70" height="8" fill="#ec4899" stroke="#831843"/><path d="M75 48 L85 45 L85 59 L75 56 Z" fill="#831843"/><rect x="25" y="56" width="15" height="10" fill="#831843"/></svg>`,
m4a4_emperor:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#fbbf24" stroke="#78350f"/><rect x="80" y="45" width="12" height="14" fill="#78350f" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#fbbf24" stroke-width="1.5"/></svg>`,
scar20:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#78350f" stroke="#451a03"/><rect x="80" y="45" width="12" height="14" fill="#451a03" rx="2"/><circle cx="25" cy="52" r="5" fill="#1f2937"/></svg>`,
cursed_awp:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="ca1" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#1f2937"/><stop offset=".5" stop-color="#7c3aed"/><stop offset="1" stop-color="#1f2937"/></linearGradient></defs><rect x="10" y="48" width="75" height="8" fill="url(#ca1)" stroke="#a855f7" stroke-width="1"/><rect x="80" y="45" width="12" height="14" fill="#1f2937" rx="2"/><circle cx="25" cy="52" r="6" fill="#1f2937" stroke="#a855f7" stroke-width="1.5"/><circle cx="25" cy="52" r="3" fill="#f97316"/><path d="M40 50 Q50 45 60 50" stroke="#a855f7" stroke-width="1" fill="none"/></svg>`,
pumpkin_gun:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="pg1" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fbbf24"/><stop offset=".5" stop-color="#f97316"/><stop offset="1" stop-color="#7c2d12"/></linearGradient></defs><rect x="10" y="48" width="70" height="8" fill="url(#pg1)" stroke="#451a03"/><path d="M75 48 L85 45 L85 59 L75 56 Z" fill="#451a03"/><circle cx="50" cy="52" r="4" fill="#1f2937"/><circle cx="48" cy="50" r="1" fill="#fbbf24"/><circle cx="52" cy="50" r="1" fill="#fbbf24"/><path d="M47 54 Q50 56 53 54" stroke="#1f2937" stroke-width="1" fill="none"/></svg>`,
ak47:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="70" height="8" fill="#92400e" stroke="#451a03"/><path d="M75 48 L85 45 L85 59 L75 56 Z" fill="#78350f"/><rect x="25" y="56" width="15" height="10" fill="#92400e"/><circle cx="20" cy="52" r="4" fill="#1f2937"/></svg>`,
m4a4:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="10" y="48" width="75" height="8" fill="#374151" stroke="#1f2937"/><rect x="80" y="45" width="12" height="14" fill="#1f2937" rx="2"/><circle cx="25" cy="52" r="5" fill="#1f2937"/><rect x="30" y="56" width="18" height="8" fill="#374151"/></svg>`,
mp9:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="20" y="48" width="50" height="10" fill="#1f2937"/><rect x="65" y="45" width="10" height="16" fill="#374151" rx="2"/><rect x="35" y="58" width="12" height="12" fill="#1f2937"/><circle cx="25" cy="53" r="4" fill="#000"/></svg>`,
ump45:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="48" width="55" height="10" fill="#374151"/><rect x="65" y="45" width="12" height="16" fill="#1f2937" rx="2"/><rect x="30" y="58" width="15" height="14" fill="#374151"/><circle cx="22" cy="53" r="4" fill="#000"/></svg>`,
famas:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="48" width="60" height="10" fill="#4b5563"/><rect x="70" y="45" width="10" height="16" fill="#374151" rx="2"/><rect x="30" y="58" width="15" height="10" fill="#4b5563"/></svg>`,
galil:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="48" width="60" height="10" fill="#78350f"/><rect x="70" y="45" width="10" height="16" fill="#451a03" rx="2"/><rect x="30" y="58" width="15" height="10" fill="#78350f"/></svg>`,
pm:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="40" height="12" fill="#374151"/><rect x="35" y="57" width="15" height="18" fill="#1f2937"/><rect x="60" y="43" width="10" height="6" fill="#4b5563"/><circle cx="30" cy="51" r="2" fill="#000"/></svg>`,
glock:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="42" height="12" fill="#1f2937"/><rect x="35" y="57" width="15" height="20" fill="#000"/><rect x="62" y="43" width="10" height="6" fill="#374151"/></svg>`,
usps:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="45" height="12" fill="#374151"/><rect x="35" y="57" width="15" height="18" fill="#1f2937"/><rect x="65" y="40" width="12" height="5" fill="#4b5563"/></svg>`,
deagle:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="20" y="42" width="50" height="15" fill="#fbbf24" stroke="#78350f"/><rect x="35" y="57" width="18" height="22" fill="#78350f"/><rect x="65" y="40" width="15" height="7" fill="#b45309"/><circle cx="28" cy="50" r="3" fill="#1f2937"/></svg>`,
p250:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="42" height="12" fill="#4b5563"/><rect x="35" y="57" width="15" height="18" fill="#1f2937"/><rect x="62" y="43" width="10" height="6" fill="#6b7280"/></svg>`,
tec9:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="40" height="12" fill="#6b7280"/><rect x="35" y="57" width="15" height="18" fill="#374151"/><rect x="60" y="43" width="10" height="6" fill="#9ca3af"/></svg>`,
fiveseven:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="25" y="45" width="42" height="12" fill="#1e40af"/><rect x="35" y="57" width="15" height="18" fill="#1e3a8a"/><rect x="62" y="43" width="10" height="6" fill="#3b82f6"/></svg>`,
bullet:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 40 Q20 50 25 60 L60 60 L70 50 L60 40 Z" fill="#fbbf24" stroke="#78350f" stroke-width="1.5"/><rect x="60" y="40" width="15" height="20" fill="#b45309" stroke="#78350f" stroke-width="1.5"/></svg>`,
bolt:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="20" fill="#6b7280" stroke="#374151" stroke-width="2"/><circle cx="50" cy="50" r="10" fill="#374151"/><path d="M50 30 L50 25 M50 70 L50 75 M30 50 L25 50 M70 50 L75 50" stroke="#374151" stroke-width="2"/></svg>`,
casing:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="30" y="35" width="40" height="30" fill="#fbbf24" stroke="#78350f" stroke-width="1.5" rx="2"/><ellipse cx="50" cy="35" rx="20" ry="4" fill="#fde68a"/><ellipse cx="50" cy="65" rx="20" ry="4" fill="#92400e"/></svg>`,
cloth:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20 30 Q30 25 40 30 Q50 35 60 30 Q70 25 80 30 L80 70 Q70 75 60 70 Q50 65 40 70 Q30 75 20 70 Z" fill="#7c3aed" stroke="#4c1d95" stroke-width="1.5"/></svg>`,
scope:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="20" y="45" width="60" height="12" fill="#1f2937" stroke="#000" stroke-width="1.5" rx="3"/><circle cx="30" cy="51" r="8" fill="#374151" stroke="#60a5fa" stroke-width="1.5"/><circle cx="70" cy="51" r="8" fill="#374151" stroke="#60a5fa" stroke-width="1.5"/></svg>`,
mag:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M35 25 L65 25 L68 75 L32 75 Z" fill="#374151" stroke="#1f2937" stroke-width="1.5"/><rect x="38" y="30" width="24" height="4" fill="#1f2937"/><rect x="38" y="38" width="24" height="4" fill="#1f2937"/><rect x="38" y="46" width="24" height="4" fill="#1f2937"/></svg>`,
target:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="35" fill="#fff" stroke="#000" stroke-width="3"/><circle cx="50" cy="50" r="25" fill="#ef4444"/><circle cx="50" cy="50" r="15" fill="#fff"/><circle cx="50" cy="50" r="7" fill="#ef4444"/></svg>`,
pumpkin:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><radialGradient id="pmk"><stop offset="0" stop-color="#fbbf24"/><stop offset="1" stop-color="#7c2d12"/></radialGradient></defs><ellipse cx="50" cy="55" rx="35" ry="30" fill="url(#pmk)" stroke="#451a03" stroke-width="2"/><path d="M45 25 Q50 15 55 25" stroke="#166534" stroke-width="3" fill="none"/><circle cx="38" cy="50" r="5" fill="#1f2937"/><circle cx="62" cy="50" r="5" fill="#1f2937"/><path d="M35 65 L42 60 L50 68 L58 60 L65 65" stroke="#1f2937" stroke-width="2" fill="none"/></svg>`,
ghost:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 50 Q25 20 50 20 Q75 20 75 50 L75 80 L65 70 L55 80 L45 70 L35 80 L25 70 Z" fill="#e9d5ff" stroke="#7c3aed" stroke-width="2"/><circle cx="40" cy="45" r="4" fill="#1f2937"/><circle cx="60" cy="45" r="4" fill="#1f2937"/><ellipse cx="50" cy="60" rx="4" ry="6" fill="#1f2937"/></svg>`,
bat:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M50 50 L15 30 L25 45 L10 50 L30 55 L50 60 L70 55 L90 50 L75 45 L85 30 Z" fill="#1f2937" stroke="#7c2d12" stroke-width="1.5"/><circle cx="45" cy="48" r="2" fill="#ef4444"/><circle cx="55" cy="48" r="2" fill="#ef4444"/></svg>`,
case_basic:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#6b7280" stroke="#374151" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#4b5563"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/></svg>`,
case_standard:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#3b82f6" stroke="#1e40af" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#2563eb"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/></svg>`,
case_premium:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#8b5cf6" stroke="#5b21b6" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#7c3aed"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/></svg>`,
case_legendary:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#ef4444" stroke="#991b1b" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#dc2626"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/></svg>`,
case_elite:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#fbbf24" stroke="#b45309" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#f59e0b"/><rect x="45" y="40" width="10" height="15" fill="#fff"/></svg>`,
case_gloves:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#14b8a6" stroke="#0f766e" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#0f766e"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/></svg>`,
case_knife:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#f59e0b" stroke="#78350f" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#b45309"/><rect x="45" y="40" width="10" height="15" fill="#fff"/></svg>`,
case_halloween:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#f97316" stroke="#7c2d12" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#7c2d12"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/><circle cx="35" cy="60" r="3" fill="#1f2937"/><circle cx="65" cy="60" r="3" fill="#1f2937"/><path d="M40 70 L50 65 L60 70" stroke="#1f2937" stroke-width="2" fill="none"/></svg>`,
case_cursed:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#7c3aed" stroke="#581c87" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#581c87"/><rect x="45" y="40" width="10" height="15" fill="#a855f7"/><path d="M35 60 Q50 70 65 60" stroke="#fbbf24" stroke-width="2" fill="none"/><circle cx="40" cy="65" r="2" fill="#fbbf24"/><circle cx="60" cy="65" r="2" fill="#fbbf24"/></svg>`,
case_blood:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect x="15" y="30" width="70" height="50" fill="#dc2626" stroke="#7f1d1d" stroke-width="2" rx="3"/><rect x="15" y="30" width="70" height="15" fill="#7f1d1d"/><rect x="45" y="40" width="10" height="15" fill="#fbbf24"/><path d="M30 55 Q35 65 40 55 Q45 65 50 55 Q55 65 60 55 Q65 65 70 55" stroke="#7f1d1d" stroke-width="2" fill="none"/></svg>`,
gloves_sport:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#14b8a6" stroke="#022c22" stroke-width="2"/></svg>`,
gloves_driver:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#92400e" stroke="#1f2937" stroke-width="2"/><circle cx="45" cy="65" r="4" fill="#111827"/><circle cx="55" cy="66" r="4" fill="#111827"/></svg>`,
gloves_specialist:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#7f1d1d" stroke="#000" stroke-width="2"/></svg>`,
gloves_moto:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#1f2937" stroke="#ef4444" stroke-width="2"/><path d="M35 55 L60 60" stroke="#ef4444" stroke-width="2"/></svg>`,
gloves_war:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#4b5563" stroke="#fbbf24" stroke-width="2"/><path d="M40 45 L55 50 L45 60" stroke="#fbbf24" stroke-width="1.5" fill="none"/></svg>`,
gloves_blood:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><linearGradient id="gb2" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fecaca"/><stop offset=".5" stop-color="#dc2626"/><stop offset="1" stop-color="#450a0a"/></linearGradient></defs><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="url(#gb2)" stroke="#1f2937" stroke-width="2"/><circle cx="40" cy="55" r="2" fill="#7f1d1d"/><circle cx="55" cy="60" r="2" fill="#7f1d1d"/><circle cx="60" cy="50" r="1.5" fill="#7f1d1d"/></svg>`,
gloves_web:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M25 65 L20 38 Q20 32 25 32 Q29 32 30 38 L32 50 L34 28 Q35 22 40 23 Q44 24 43 30 L42 50 L46 27 Q47 22 52 23 Q56 24 55 30 L52 51 L58 32 Q60 27 64 29 Q68 31 66 37 L60 58 Q72 50 77 55 Q82 61 70 72 Q58 84 40 82 Q28 80 25 65Z" fill="#1f2937" stroke="#a855f7" stroke-width="2"/><path d="M35 45 L55 55 M35 55 L55 45 M45 40 L45 60 M30 50 L60 50" stroke="#a855f7" stroke-width=".8" opacity=".7"/></svg>`,
avatar_skuf:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#fbbf24"/><circle cx="35" cy="40" r="5" fill="#000"/><circle cx="65" cy="40" r="5" fill="#000"/><path d="M30 65 Q50 80 70 65" stroke="#000" stroke-width="3" fill="none"/><path d="M20 25 Q50 10 80 25" stroke="#78350f" stroke-width="8" fill="none"/></svg>`,
avatar_knife:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#1f2937"/><path d="M30 70 L50 20 L70 70 Z" fill="#d1d5db" stroke="#f97316" stroke-width="2"/></svg>`,
avatar_case:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#7c3aed"/><rect x="25" y="35" width="50" height="35" fill="#581c87" stroke="#f97316" stroke-width="2" rx="3"/><rect x="45" y="45" width="10" height="15" fill="#f97316"/></svg>`,
avatar_pacman:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#f97316"/><path d="M50 50 L95 30 L95 70 Z" fill="#0a0a0f"/><circle cx="50" cy="35" r="4" fill="#000"/></svg>`,
avatar_crown:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#7c2d12"/><path d="M20 60 L30 35 L40 55 L50 30 L60 55 L70 35 L80 60 Z" fill="#fbbf24" stroke="#451a03" stroke-width="2"/></svg>`,
avatar_skull:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#0a0a0f"/><circle cx="50" cy="45" r="25" fill="#f3f4f6"/><circle cx="40" cy="42" r="5" fill="#000"/><circle cx="60" cy="42" r="5" fill="#000"/><path d="M40 60 L45 55 L50 60 L55 55 L60 60" stroke="#000" stroke-width="2" fill="none"/></svg>`,
avatar_pumpkin:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#f97316" stroke="#7c2d12" stroke-width="3"/><circle cx="38" cy="45" r="6" fill="#1f2937"/><circle cx="62" cy="45" r="6" fill="#1f2937"/><path d="M35 65 L42 60 L50 68 L58 60 L65 65" stroke="#1f2937" stroke-width="3" fill="none"/><path d="M45 20 Q50 10 55 20" stroke="#166534" stroke-width="4" fill="none"/></svg>`,
avatar_ghost:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="45" fill="#a855f7"/><path d="M25 50 Q25 20 50 20 Q75 20 75 50 L75 80 L65 70 L55 80 L45 70 L35 80 L25 70 Z" fill="#e9d5ff" stroke="#581c87" stroke-width="2"/><circle cx="40" cy="45" r="4" fill="#1f2937"/><circle cx="60" cy="45" r="4" fill="#1f2937"/></svg>`
};
function iconUrl(k){return 'data:image/svg+xml;utf8,'+encodeURIComponent(ICONS[k])}

// ============ ПРЕДМЕТЫ ============
const allItems={
common:[
{name:'Пустой патрон',icon:'bullet',price:5},
{name:'Ржавый болт',icon:'bolt',price:10},
{name:'Старая гильза',icon:'casing',price:15},
{name:'Кусок ткани',icon:'cloth',price:8},
{name:'Сломанный прицел',icon:'scope',price:12},
{name:'Пустая обойма',icon:'mag',price:7},
{name:'Погнутый гвоздь',icon:'bolt',price:6},
{name:'Обрывок верёвки',icon:'cloth',price:4}
],
rare:[
{name:'Пистолет ПМ',icon:'pm',price:80},
{name:'Glock-18',icon:'glock',price:120},
{name:'USP-S',icon:'usps',price:150},
{name:'Desert Eagle',icon:'deagle',price:200},
{name:'P250',icon:'p250',price:90},
{name:'Tec-9',icon:'tec9',price:110},
{name:'Five-SeveN',icon:'fiveseven',price:130}
],
epic:[
{name:'AK-47',icon:'ak47',price:350},
{name:'M4A4',icon:'m4a4',price:400},
{name:'MP9',icon:'mp9',price:280},
{name:'UMP-45',icon:'ump45',price:320},
{name:'FAMAS',icon:'famas',price:300},
{name:'Galil AR',icon:'galil',price:290},
{name:'SCAR-20',icon:'scar20',price:380}
],
legendary:[
{name:'AWP Дракон',icon:'awp_dragon',price:800},
{name:'AK Огненный',icon:'ak_fire',price:1000},
{name:'M4A1-S Зверь',icon:'m4a1_beast',price:900},
{name:'AWP Азимов',icon:'awp_asimov',price:1200},
{name:'AK Неон',icon:'ak_neon',price:1100},
{name:'M4A4 Император',icon:'m4a4_emperor',price:950},
{name:'AWP Gungnir',icon:'awp_gungnir',price:1500}
],
knife:[
{name:'Керамбит',icon:'karambit',price:2500},
{name:'Бабочка',icon:'butterfly',price:3000},
{name:'M9 Штык-нож',icon:'m9bayonet',price:3500},
{name:'Тычковые ножи',icon:'talon',price:2800},
{name:'Флип-нож',icon:'flip',price:2200},
{name:'Скелетный нож',icon:'skeleton',price:3200},
{name:'Нож-клык',icon:'fang',price:3800},
{name:'Нож охотника',icon:'hunter',price:2600},
{name:'Наварский нож',icon:'navaja',price:2400},
{name:'Штык-нож',icon:'bayonet',price:2900},
{name:'Стилет',icon:'stiletto',price:2700},
{name:'Ursus нож',icon:'ursus',price:3100}
],
gloves:[
{name:'Спортивные | Бирюза',icon:'gloves_sport',price:1800},
{name:'Спортивные | Мусорный люкс',icon:'gloves_sport',price:2400},
{name:'Водительские | Коричневый скам',icon:'gloves_driver',price:1600},
{name:'Водительские | Золотой скуф',icon:'gloves_driver',price:2800},
{name:'Специалист | Красный фартук',icon:'gloves_specialist',price:3200},
{name:'Специалист | Полевой мусор',icon:'gloves_specialist',price:4200},
{name:'Мото | Кожаные',icon:'gloves_moto',price:2200},
{name:'Боевые | Тактические',icon:'gloves_war',price:3500}
],
// 🎃 ХЭЛЛОУИН ЛИМИТКИ (только за алмазы)
halloween:[
{name:'🎃 Тыква-Керамбит',icon:'pumpkin_karambit',price:5000,limited:true},
{name:'👻 Призрак-Бабочка',icon:'ghost_butterfly',price:6000,limited:true},
{name:'🧙 Ведьмин Клинок',icon:'witch_blade',price:5500,limited:true},
{name:'🩸 Кровавые Тычковые',icon:'blood_talon',price:4800,limited:true},
{name:'🕷️ Паучий Флип',icon:'spider_flip',price:4500,limited:true},
{name:'🎃 Проклятый AWP',icon:'cursed_awp',price:3500,limited:true},
{name:'🎃 Тыквомёт',icon:'pumpkin_gun',price:2800,limited:true},
{name:'🩸 Кровавые перчатки',icon:'gloves_blood',price:4200,limited:true},
{name:'🕸️ Паутина | specialist',icon:'gloves_web',price:3800,limited:true}
]
};

const allUpgradeTargets=[
...allItems.rare.map(i=>({...i,rarity:'rare'})),
...allItems.epic.map(i=>({...i,rarity:'epic'})),
...allItems.legendary.map(i=>({...i,rarity:'legendary'})),
...allItems.gloves.map(i=>({...i,rarity:'gloves'})),
...allItems.knife.map(i=>({...i,rarity:'knife'})),
...allItems.halloween.map(i=>({...i,rarity:'halloween'}))
];

// ============ КЕЙСЫ ============
const cases=[
{id:'basic',name:'Базовый',icon:'case_basic',price:50,currency:'rub',class:'case-basic',chanceText:'🗡️0.5%|🧤0.3%',chances:{common:75,rare:20,epic:3.5,legendary:0.7,knife:0.5,gloves:0.3}},
{id:'standard',name:'Стандартный',icon:'case_standard',price:100,currency:'rub',class:'case-standard',chanceText:'🗡️1%|🧤0.5%',chances:{common:60,rare:28,epic:8,legendary:2,knife:1,gloves:0.5}},
{id:'premium',name:'Премиум',icon:'case_premium',price:250,currency:'rub',class:'case-premium',chanceText:'🗡️2%|🧤1%',chances:{common:40,rare:35,epic:15,legendary:5,knife:2,gloves:1}},
{id:'legendary',name:'Легендарный',icon:'case_legendary',price:500,currency:'rub',class:'case-legendary',chanceText:'🗡️3%|🧤1.5%',chances:{common:20,rare:35,epic:25,legendary:10,knife:3,gloves:1.5}},
{id:'elite',name:'Элитный',icon:'case_elite',price:1000,currency:'rub',class:'case-elite',chanceText:'🗡️5%|🧤2.5%',chances:{common:10,rare:25,epic:35,legendary:20,knife:5,gloves:2.5}},
{id:'glove',name:'Перчаточный',icon:'case_gloves',price:750,currency:'rub',class:'case-gloves',chanceText:'🧤 100% перчатки',chances:{rare:30,epic:40,legendary:20,gloves:10}},
{id:'knife',name:'Ножевой',icon:'case_knife',price:1500,currency:'rub',class:'case-knife',chanceText:'🗡️ 100% ножи',chances:{rare:25,epic:40,legendary:20,knife:15}},
// 🎃 ХЭЛЛОУИН КЕЙСЫ ЗА АЛМАЗЫ
{id:'pumpkin',name:'🎃 Тыквенный',icon:'case_halloween',price:50,currency:'diamond',class:'case-halloween',chanceText:'💎 50 алмазов',limited:true,chances:{common:30,rare:30,epic:20,legendary:10,halloween:10}},
{id:'cursed',name:'👻 Проклятый',icon:'case_cursed',price:100,currency:'diamond',class:'case-cursed',chanceText:'💎 100 алмазов',limited:true,chances:{rare:25,epic:30,legendary:25,halloween:20}},
{id:'blood',name:'🩸 Кровавый',icon:'case_blood',price:200,currency:'diamond',class:'case-blood',chanceText:'💎 200 алмазов',limited:true,chances:{epic:25,legendary:35,halloween:40}}
];

let balance=1000,diamonds=0,inventory=[],isOpening=false,selectedCase=cases[0],animationSpeed='normal';
const SPEEDS={fast:{roulette:1,multiDelay:30},normal:{roulette:3,multiDelay:80},slow:{roulette:7,multiDelay:180}};
const balanceEl=document.getElementById('balance');
const diamondsEl=document.getElementById('diamonds');
function updateBalance(){balanceEl.textContent=balance;diamondsEl.textContent=diamonds}
function topup(){balance+=500;updateBalance();SFX.coin();notify('💰 +500 ₽','#10b981',null,randMeme(MEMES.topup));addBPXP(5)}
function switchTab(tab,btn){
SFX.click();
document.querySelectorAll('.tab').forEach(t=>t.classList.remove('active'));
document.querySelectorAll('.section').forEach(s=>s.classList.remove('active'));
btn.classList.add('active');
document.getElementById('section-'+tab).classList.add('active');
if(tab==='upgrade')renderUpgradePanels();
if(tab==='profile')renderProfile();
if(tab==='trades')renderTradePanel();
if(tab==='daily')renderDailyRewards();
if(tab==='battlepass')renderBattlePass();
}
function setSpeed(s,btn){SFX.click();animationSpeed=s;document.querySelectorAll('.speed-btn').forEach(b=>b.classList.remove('active'));btn.classList.add('active')}

function notify(text,color,iconKey,meme){
const n=document.createElement('div');n.className='notification';
const iconHtml=iconKey?`<img src="${iconUrl(iconKey)}">`:'';
const memeHtml=meme?`<div class="meme">${meme}</div>`:'';
n.innerHTML=iconHtml+`<div><div>${text}</div>${memeHtml}</div>`;
n.style.borderColor=color;document.body.appendChild(n);
setTimeout(()=>n.remove(),3500);
}

function renderCases(){
const g=document.getElementById('casesGrid');g.innerHTML='';
cases.forEach(c=>{
const d=document.createElement('div');
d.className=`case-card ${c.class} ${c.id===selectedCase.id?'selected':''}`;
const limitedBadge=c.limited?'<div class="limited-badge">💎 LIMIT</div>':'';
const priceClass=c.currency==='diamond'?'price diamond':'price';
const priceSymbol=c.currency==='diamond'?'💎':'₽';
d.innerHTML=`${limitedBadge}<button class="view-btn" onclick="event.stopPropagation();showDropModal('${c.id}')">👁️</button><img src="${iconUrl(c.icon)}"><div class="name">${c.name}</div><div class="${priceClass}">${c.price} ${priceSymbol}</div><div class="chance">${c.chanceText}</div>`;
d.onclick=()=>{SFX.click();selectCase(c)};g.appendChild(d);
});
updatePrices();
}
function updatePrices(){
const sym=selectedCase.currency==='diamond'?'💎':'₽';
document.getElementById('price1').textContent=selectedCase.price+' '+sym;
document.getElementById('price5').textContent=selectedCase.price*5+' '+sym;
document.getElementById('price10').textContent=selectedCase.price*10+' '+sym;
}
function selectCase(c){if(isOpening)return;selectedCase=c;document.getElementById('currentCaseName').textContent=`Выбран: ${c.name} — ${c.price} ${c.currency==='diamond'?'💎':'₽'}`;renderCases()}

function showDropModal(caseId){
SFX.click();
const c=cases.find(x=>x.id===caseId);
document.getElementById('dropModalTitle').textContent=`🎃 ${c.name} — ${c.price} ${c.currency==='diamond'?'💎':'₽'}`;
const list=document.getElementById('dropList');list.innerHTML='';
Object.entries(c.chances).forEach(([rarity,chance])=>{
if(chance<=0)return;
const items=allItems[rarity];if(!items)return;
items.forEach(item=>{
const perItemChance=(chance/items.length).toFixed(2);
const d=document.createElement('div');
d.className=`drop-item rarity-${rarity}`;
const limited=item.limited?' 💎':'';
d.innerHTML=`<img src="${iconUrl(item.icon)}"><div class="drop-info"><div class="drop-name">${item.name}${limited}</div><div class="drop-price">${item.price} ₽</div></div><div class="drop-chance">${perItemChance}%</div>`;
list.appendChild(d);
});
});
document.getElementById('dropModal').classList.add('active');
}
function closeDropModal(){document.getElementById('dropModal').classList.remove('active')}

function getRandomItem(cd){
const r=Math.random()*100;let c=0,ch='common';
for(const[k,v]of Object.entries(cd.chances)){c+=v;if(r<=c){ch=k;break}}
const p=allItems[ch];if(!p||!p.length)return{...allItems.common[0],rarity:'common'};
return{...p[Math.floor(Math.random()*p.length)],rarity:ch};
}
function mkItemEl(it){
const d=document.createElement('div');d.className=`roulette-item rarity-${it.rarity}`;
const wearTag=it.wear?`<div class="wear-tag" style="color:${it.wear.color}">${it.wear.name}</div>`:'';
const stattrakTag=it.stattrak?'<div class="wear-tag" style="background:#f97316;color:#fff;left:2px;right:auto">ST™</div>':'';
d.innerHTML=`${stattrakTag}${wearTag}<img src="${iconUrl(it.icon)}"><div class="iname">${it.name}</div>`;return d;
}
function setBtns(d){['openBtn1','openBtn5','openBtn10'].forEach(id=>document.getElementById(id).disabled=d)}

function openCase(count){
if(isOpening)return;
const cost=selectedCase.price*count;
const curr=selectedCase.currency;
const have=curr==='diamond'?diamonds:balance;
if(have<cost){notify(`❌ Нужно ${cost} ${curr==='diamond'?'💎':'₽'}`,'#ff4444',null,randMeme(MEMES.lose));SFX.lose();return}
isOpening=true;
if(curr==='diamond')diamonds-=cost;else balance-=cost;
updateBalance();setBtns(true);
SFX.open();
if(selectedCase.limited)SFX.halloween();
mcProfile.stats.casesOpened+=count;
mcProfile.stats.spent+=curr==='rub'?cost:0;
addMCXP(count*12);addBPXP(count*10);
completeQuest('openCases',count);
saveMCProfile();
const wins=[];
for(let i=0;i<count;i++){
const item=getRandomItem(selectedCase);
item.wear=rollWear();
item.stattrak=rollStattrak(item.rarity==='knife'||item.rarity==='halloween'?20:5);
if(item.stattrak)item.killCount=Math.floor(Math.random()*100);
wins.push(item);
}
const sp=SPEEDS[animationSpeed],dur=sp.roulette;
if(count===1){
const rc=document.getElementById('rouletteContainer'),rt=document.getElementById('rouletteTrack'),mr=document.getElementById('multiResults');
rc.style.display='block';mr.style.display='none';
rt.style.transition='none';rt.style.transform='translateX(0)';rt.innerHTML='';
const w=wins[0],total=70,pos=55;
for(let i=0;i<total;i++)rt.appendChild(mkItemEl(i===pos?w:getRandomItem(selectedCase)));
let tickCount=0;
const tickInterval=setInterval(()=>{SFX.tick();tickCount++;if(tickCount>dur*20)clearInterval(tickInterval)},50);
setTimeout(()=>{
const iw=116,cc=rc.offsetWidth/2,to=pos*iw+iw/2,ro=(Math.random()-.5)*60,fo=to-cc+ro;
rt.style.transition=`transform ${dur}s cubic-bezier(.15,.85,.35,1)`;
rt.style.transform=`translateX(-${fo}px)`;
},50);
setTimeout(()=>{
clearInterval(tickInterval);
inventory.push({...w,id:Date.now()+Math.random()});renderInventory();
const cols={knife:'#ffd700',gloves:'#14b8a6',legendary:'#ef4444',epic:'#8b5cf6',rare:'#3b82f6',common:'#718096',halloween:'#f97316'};
let memePool=MEMES.commonWin;
if(w.rarity==='halloween'){memePool=MEMES.halloween;SFX.knife();SFX.halloween();showBigMeme('🎃','ЛИМИТКА!!!',randMeme(MEMES.halloween));completeQuest('getHalloween',1)}
else if(w.rarity==='knife'){memePool=MEMES.knifeWin;SFX.knife();showBigMeme('🗡️','НОЖ!!!',randMeme(MEMES.knifeWin));completeQuest('getKnife',1)}
else if(w.rarity==='gloves'){memePool=MEMES.legendaryWin;SFX.win();showBigMeme('🧤','ПЕРЧАТКИ!',randMeme(MEMES.legendaryWin));completeQuest('getGloves',1)}
else if(w.rarity==='legendary'){memePool=MEMES.legendaryWin;SFX.win();completeQuest('getLegendary',1)}
else if(w.rarity==='epic'){memePool=MEMES.epicWin;SFX.win()}
else if(w.rarity==='rare'){memePool=MEMES.rareWin;SFX.coin()}
else{SFX.lose()}
const wearText=w.wear?` [${w.wear.name}]`:'';
const statText=w.stattrak?' StatTrak™':'';
notify(`${w.name}${wearText}${statText} — ${w.price} ₽`,cols[w.rarity],w.icon,randMeme(memePool));
isOpening=false;setBtns(false);
},dur*1000+200);
}else{
document.getElementById('rouletteContainer').style.display='none';
const mr=document.getElementById('multiResults'),mg=document.getElementById('multiGrid'),ms=document.getElementById('multiStats');
mr.style.display='block';mg.innerHTML='';
ms.innerHTML='<div style="text-align:center;width:100%;padding:12px;color:#f97316">🎃 Открываем...</div>';
let tw=0,kc=0,gc=0,hc=0;
wins.forEach((it,idx)=>{
inventory.push({...it,id:Date.now()+Math.random()+idx});
tw+=it.price;
if(it.rarity==='knife'){kc++;completeQuest('getKnife',1)}
if(it.rarity==='gloves'){gc++;completeQuest('getGloves',1)}
if(it.rarity==='halloween'){hc++;completeQuest('getHalloween',1)}
if(it.rarity==='legendary')completeQuest('getLegendary',1);
setTimeout(()=>{
SFX.tick();
const d=document.createElement('div');
d.className=`multi-item rarity-${it.rarity}`;
const wearTag=it.wear?`<div class="wear" style="color:${it.wear.color}">${it.wear.name}</div>`:'';
d.innerHTML=`<img src="${iconUrl(it.icon)}"><div class="name">${it.name}</div>${wearTag}<div class="price">${it.price} ₽</div>`;
mg.appendChild(d);
},idx*sp.multiDelay);
});
setTimeout(()=>{
const p=tw-cost*(curr==='diamond'?10:1),pc=p>=0?'profit':'loss',ps=p>=0?'+':'';
ms.innerHTML=`<div class="stat-box"><div class="label">Потрачено</div><div class="value">${cost} ${curr==='diamond'?'💎':'₽'}</div></div><div class="stat-box"><div class="label">Выиграно</div><div class="value" style="color:#7fff00">${tw} ₽</div></div><div class="stat-box"><div class="label">Профит</div><div class="value" style="color:${pc==='profit'?'#7fff00':'#ef4444'}">${ps}${p} ₽</div></div>${kc>0?`<div class="stat-box"><div class="label">🗡️ Ножей</div><div class="value" style="color:#ffd700">${kc}</div></div>`:''}${gc>0?`<div class="stat-box"><div class="label">🧤 Перчаток</div><div class="value" style="color:#14b8a6">${gc}</div></div>`:''}${hc>0?`<div class="stat-box"><div class="label">🎃 Лимиток</div><div class="value" style="color:#f97316">${hc}</div></div>`:''}`;
renderInventory();
if(hc>0){SFX.knife();SFX.halloween();showBigMeme('🎃',`${hc} ЛИМИТКА!`,randMeme(MEMES.halloween));notify(`🎃 ДЖЕКПОТ! ${hc} лимиток!`,'#f97316',null,randMeme(MEMES.halloween))}
else if(kc>0){SFX.knife();showBigMeme('🗡️',`${kc} НОЖ(А)!`,randMeme(MEMES.knifeWin));notify(`🗡️ ДЖЕКПОТ!`,'#ffd700',null,randMeme(MEMES.knifeWin))}
else if(gc>0){SFX.win();showBigMeme('🧤',`${gc} ПЕРЧАТКИ!`,randMeme(MEMES.legendaryWin));notify(`🧤 ${gc} перчаток!`,'#14b8a6',null,randMeme(MEMES.legendaryWin))}
else if(p>=0){SFX.win();notify(`В плюсе на ${p} ₽`,'#7fff00')}
else{SFX.lose();notify(`Убыток ${Math.abs(p)} ₽`,'#ef4444')}
isOpening=false;setBtns(false);
},wins.length*sp.multiDelay+500);
}
}

function renderInventory(){
const ic=document.getElementById('invCount'),ig=document.getElementById('inventoryGrid');
ic.textContent=inventory.length;
if(inventory.length===0){ig.innerHTML='<div class="empty">Инвентарь пуст</div>';return}
ig.innerHTML='';
[...inventory].sort((a,b)=>{
const o={halloween:0,knife:1,gloves:2,legendary:3,epic:4,rare:5,common:6};
return (o[a.rarity]||99)-(o[b.rarity]||99)||b.price-a.price;
}).forEach(it=>{
const d=document.createElement('div');d.className=`inv-item rarity-${it.rarity}`;
const wearTag=it.wear?`<div class="wear-tag" style="color:${it.wear.color}">${it.wear.name}</div>`:'';
const stattrakTag=it.stattrak?`<div class="stattrak">ST™${it.killCount||0}</div>`:'';
d.innerHTML=`${stattrakTag}${wearTag}<img src="${iconUrl(it.icon)}"><div class="name">${it.name}</div><div class="price">${it.price} ₽</div>`;
d.onclick=()=>{SFX.coin();sellItem(it.id)};ig.appendChild(d);
});
}
function sellItem(id){
const it=inventory.find(i=>i.id===id);if(!it)return;
balance+=it.price;inventory=inventory.filter(i=>i.id!==id);
updateBalance();renderInventory();notify(`💸 ${it.name} за ${it.price} ₽`,'#7fff00',it.icon);
renderUpgradePanels();
}
function sellAll(){
if(inventory.length===0)return;
const t=inventory.reduce((s,i)=>s+i.price,0);
balance+=t;inventory=[];updateBalance();renderInventory();
SFX.coin();notify(`💸 Продано всё за ${t} ₽`,'#7fff00');renderUpgradePanels();
}

// ============ КОЛЕСО ============
const wheelCanvas=document.getElementById('wheelCanvas'),wheelCtx=wheelCanvas.getContext('2d');
let wheelRotation=0,isSpinning=false;
const WHEEL_SEGS=[{t:'knife'},{t:'bullet'},{t:'bullet'},{t:'knife'},{t:'bullet'},{t:'bullet'},{t:'bullet'},{t:'knife'},{t:'bullet'},{t:'bullet'}];
const wKI=new Image();wKI.src=iconUrl('pumpkin_karambit');
const wBI=new Image();wBI.src=iconUrl('bullet');
document.getElementById('wheelKnifeImg').src=iconUrl('pumpkin_karambit');
document.getElementById('wheelBulletImg').src=iconUrl('bullet');
document.getElementById('wheelCenterImg').src=iconUrl('pumpkin');

function drawWheel(){
const cx=wheelCanvas.width/2,cy=wheelCanvas.height/2,r=cx-5,n=WHEEL_SEGS.length,sa=Math.PI*2/n;
for(let i=0;i<n;i++){
const s=i*sa,e=s+sa,isK=WHEEL_SEGS[i].t==='knife';
const g=wheelCtx.createRadialGradient(cx,cy,20,cx,cy,r);
if(isK){g.addColorStop(0,'#fbbf24');g.addColorStop(1,'#7c2d12')}
else{g.addColorStop(0,'#6b7280');g.addColorStop(1,'#1f2937')}
wheelCtx.beginPath();wheelCtx.moveTo(cx,cy);wheelCtx.arc(cx,cy,r,s,e);wheelCtx.closePath();
wheelCtx.fillStyle=g;wheelCtx.fill();wheelCtx.strokeStyle='#f97316';wheelCtx.lineWidth=2;wheelCtx.stroke();
wheelCtx.save();wheelCtx.translate(cx,cy);wheelCtx.rotate(s+sa/2);
wheelCtx.textAlign='center';wheelCtx.fillStyle='#fff';wheelCtx.font='bold 11px Arial';
wheelCtx.fillText(isK?'+2500₽':'0₽',r*.42,4);wheelCtx.restore();
const im=isK?wKI:wBI;
if(im.complete&&im.naturalWidth>0){
wheelCtx.save();wheelCtx.translate(cx,cy);wheelCtx.rotate(s+sa/2);
wheelCtx.drawImage(im,r*.65-12,-12,24,24);wheelCtx.restore();
}
}
wheelCtx.beginPath();wheelCtx.arc(cx,cy,r,0,Math.PI*2);
wheelCtx.strokeStyle='#f97316';wheelCtx.lineWidth=3;wheelCtx.stroke();
}
let il=0;function onIL(){il++;if(il>=2)drawWheel()}
wKI.onload=onIL;wBI.onload=onIL;
setTimeout(()=>{if(il<2)drawWheel()},500);

function spinWheel(){
if(isSpinning)return;
if(balance<500){notify('❌ Нужно 500 ₽','#ff4444');SFX.lose();return}
isSpinning=true;balance-=500;updateBalance();
document.getElementById('wheelBtn').disabled=true;
document.getElementById('wheelResult').textContent='';
SFX.open();
mcProfile.stats.wheelSpins++;
mcProfile.stats.spent+=500;
addMCXP(15);addBPXP(15);
saveMCProfile();
const isWin=Math.random()<.3;
const n=WHEEL_SEGS.length,sa=360/n;
const ki=WHEEL_SEGS.map((s,i)=>s.t==='knife'?i:-1).filter(i=>i>=0);
const bi=WHEEL_SEGS.map((s,i)=>s.t==='bullet'?i:-1).filter(i=>i>=0);
const ts=isWin?ki[Math.floor(Math.random()*ki.length)]:bi[Math.floor(Math.random()*bi.length)];
const sc=ts*sa+sa/2,fs=6+Math.floor(Math.random()*3);
const fr=wheelRotation+fs*360+(270-sc)+(Math.random()-.5)*sa*.6;
wheelCanvas.style.transition='transform 5s cubic-bezier(.17,.67,.21,.99)';
wheelCanvas.style.transform=`rotate(${fr}deg)`;wheelRotation=fr;
let wheelTicks=0;
const wheelTickInt=setInterval(()=>{SFX.wheel();wheelTicks++;if(wheelTicks>50)clearInterval(wheelTickInt)},100);
setTimeout(()=>{
clearInterval(wheelTickInt);
const wr=document.getElementById('wheelResult');
if(isWin){
balance+=2500;updateBalance();
wr.innerHTML=`<img src="${iconUrl('pumpkin_karambit')}" style="width:28px;height:28px;vertical-align:middle"> 🎃 НОЖ! +2500 ₽`;
wr.className='wheel-result win';
SFX.knife();SFX.halloween();showBigMeme('🎃','+2500 ₽',randMeme(MEMES.halloween));
notify('🎃 ДЖЕКПОТ! +2500 ₽','#f97316','pumpkin_karambit',randMeme(MEMES.halloween));
}else{
wr.innerHTML=`<img src="${iconUrl('bullet')}" style="width:28px;height:28px;vertical-align:middle"> 🔩 Патрон... 0 ₽`;
wr.className='wheel-result lose';
SFX.lose();notify('🔩 Патрон... 0 ₽','#718096','bullet',randMeme(MEMES.lose));
}
isSpinning=false;document.getElementById('wheelBtn').disabled=false;
},5100);
}

// ============ АПГРЕЙДЕР ============
let selSrcId=null,selTgtKey=null,isUpgrading=false;

function renderUpgradePanels(){
const us=document.getElementById('upgradeSource'),ut=document.getElementById('upgradeTarget');
us.innerHTML='';
if(inventory.length===0)us.innerHTML='<div class="empty">Инвентарь пуст</div>';
else inventory.forEach(it=>{
const d=document.createElement('div');
d.className=`upgrade-item rarity-${it.rarity} ${selSrcId===it.id?'selected':''}`;
const wearTag=it.wear?`<div class="wear-tag" style="color:${it.wear.color}">${it.wear.name}</div>`:'';
d.innerHTML=`${wearTag}<img src="${iconUrl(it.icon)}"><div class="name">${it.name}</div><div class="price">${it.price} ₽</div>`;
d.onclick=()=>{if(isUpgrading)return;SFX.click();selSrcId=it.id;renderUpgradePanels()};
us.appendChild(d);
});
ut.innerHTML='';
allUpgradeTargets.forEach(it=>{
const k=it.name+'_'+it.price;
const d=document.createElement('div');
d.className=`upgrade-item rarity-${it.rarity} ${selTgtKey===k?'selected':''}`;
d.innerHTML=`<img src="${iconUrl(it.icon)}"><div class="name">${it.name}</div><div class="price">${it.price} ₽</div>`;
d.onclick=()=>{if(isUpgrading)return;SFX.click();selTgtKey=k;renderUpgradePanels()};
ut.appendChild(d);
});
updateUpgradeCircle();updateUpgradeBtn();
}
function getSrc(){return inventory.find(i=>i.id===selSrcId)}
function getTgt(){if(!selTgtKey)return null;return allUpgradeTargets.find(i=>i.name+'_'+i.price===selTgtKey)}
function calcChance(){
const s=getSrc(),t=getTgt();
if(!s||!t||s.price>=t.price)return 0;
let c=(s.price/t.price)*90;
return Math.max(3,Math.min(85,Math.round(c*10)/10));
}
function updateUpgradeCircle(){
const cv=document.getElementById('upgradeCanvas'),cx=cv.getContext('2d');
const ch=calcChance(),c=cv.width/2,r=c-10;
cx.clearRect(0,0,cv.width,cv.height);
cx.beginPath();cx.arc(c,c,r,0,Math.PI*2);cx.fillStyle='#7f1d1d';cx.fill();
if(ch>0){
const a=(ch/100)*Math.PI*2;
cx.beginPath();cx.moveTo(c,c);cx.arc(c,c,r,-Math.PI/2,-Math.PI/2+a);cx.closePath();
const g=cx.createRadialGradient(c,c,20,c,c,r);
g.addColorStop(0,'#f97316');g.addColorStop(1,'#7c2d12');cx.fillStyle=g;cx.fill();
}
cx.beginPath();cx.arc(c,c,r,0,Math.PI*2);cx.strokeStyle='#f97316';cx.lineWidth=3;cx.stroke();
const pe=document.getElementById('upgradePercent');
if(ch>0){pe.textContent=ch+'%';pe.style.color=ch>50?'#7fff00':ch>20?'#fbbf24':'#ef4444'}
else{pe.textContent='—%';pe.style.color='#fff'}
}
function updateUpgradeBtn(){document.getElementById('upgradeBtn').disabled=calcChance()<=0}

function doUpgrade(){
if(isUpgrading)return;
const ch=calcChance();if(ch<=0)return;
const s=getSrc(),t=getTgt();if(!s||!t)return;
isUpgrading=true;
document.getElementById('upgradeBtn').disabled=true;
document.getElementById('upgradeResult').textContent='';
SFX.upgrade();
mcProfile.stats.upgradesTried++;
addMCXP(20);addBPXP(20);
completeQuest('doUpgrade',1);
saveMCProfile();
const cv=document.getElementById('upgradeCanvas');
cv.style.transition='transform 4s cubic-bezier(.17,.67,.21,.99)';
const sp=5+Math.random()*3,fa=Math.random()*360;
cv.style.transform=`rotate(${sp*360+fa}deg)`;
let upTicks=0;
const upTickInt=setInterval(()=>{SFX.tick();upTicks++;if(upTicks>40)clearInterval(upTickInt)},100);
setTimeout(()=>{
clearInterval(upTickInt);
const win=Math.random()*100<ch;
inventory=inventory.filter(i=>i.id!==s.id);
const re=document.getElementById('upgradeResult');
if(win){
const newItem={...t,id:Date.now()+Math.random(),rarity:t.rarity};
newItem.wear=rollWear();
newItem.stattrak=rollStattrak(t.rarity==='halloween'||t.rarity==='knife'?25:5);
if(newItem.stattrak)newItem.killCount=0;
inventory.push(newItem);
re.textContent=`🎉 УСПЕХ! ${t.name}`;re.className='upgrade-result win';
SFX.knife();
if(t.rarity==='halloween'){SFX.halloween();showBigMeme('🎃','ЛИМИТКА!',randMeme(MEMES.halloween))}
else showBigMeme('⚡','УСПЕХ!',randMeme(MEMES.upgradeWin));
notify(`⚡ Апгрейд успешен!`,'#7fff00',t.icon,randMeme(MEMES.upgradeWin));
}else{
re.textContent=`💀 ПРОВАЛ! -${s.name}`;re.className='upgrade-result lose';
SFX.lose();notify(`💔 Апгрейд провален`,'#ef4444',s.icon,randMeme(MEMES.upgradeLose));
}
cv.style.transition='none';cv.style.transform='rotate(0deg)';
setTimeout(()=>{cv.style.transition='transform 4s cubic-bezier(.17,.67,.21,.99)'},50);
selSrcId=null;selTgtKey=null;
renderInventory();renderUpgradePanels();isUpgrading=false;
},4100);
}

// ============ ТРЕЙДЫ ============
let tradeSourceId=null,tradeOffers=[];
const BOT_NAMES=['🎃 Bot_Pumpkin','👻 GhostTrader','🕷️ SpiderBot','🧙 WitchExchange','💀 SkullMerchant','🦇 BatBaron','🕸️ WebDealer'];
const BOT_COMMENTS=['Сладость или гадость? 🎃','У меня лимитки, брат.','Это не скам, это Хэллоуин.','Быстрее, ночь коротка.','Скину паутинку сверху.','Мне по кайфу обменяться.','Соглашайся, лох.','Это халява, клянусь.','Тыкву тебе в подарок!','Ведьма одобряет 🧙'];

function getAllTradeSkins(){return Object.entries(allItems).flatMap(([r,items])=>items.map(i=>({...i,rarity:r})))}
function makeBotOffers(source){
const pool=getAllTradeSkins();
return Array.from({length:3},()=>{
const m=0.65+Math.random()*0.95;
const tp=source.price*m;
const c=pool.filter(i=>i.price>=tp*0.65&&i.price<=tp*1.35).sort(()=>Math.random()-0.5);
const item=c[0]||pool[Math.floor(Math.random()*pool.length)];
return{bot:BOT_NAMES[Math.floor(Math.random()*BOT_NAMES.length)],comment:BOT_COMMENTS[Math.floor(Math.random()*BOT_COMMENTS.length)],item};
});
}
function renderTradePanel(){
const sb=document.getElementById('tradeSource'),ob=document.getElementById('botOffers');
if(!sb||!ob)return;
sb.innerHTML='';
if(!inventory.length){sb.innerHTML='<div class="empty">Инвентарь пуст</div>';ob.innerHTML='<div class="empty">Открой кейс</div>';return}
[...inventory].sort((a,b)=>b.price-a.price).forEach(item=>{
const d=document.createElement('div');
d.className=`inv-item rarity-${item.rarity} ${tradeSourceId===item.id?'trade-selected':''}`;
d.innerHTML=`<img src="${iconUrl(item.icon)}"><div class="name">${item.name}</div><div class="price">${item.price} ₽</div>`;
d.onclick=()=>selectTradeSource(item.id);sb.appendChild(d);
});
const source=inventory.find(i=>i.id===tradeSourceId);
if(!source){ob.innerHTML='<div class="empty">Выбери скин слева</div>';return}
if(!tradeOffers.length||tradeOffers._srcId!==tradeSourceId){tradeOffers=makeBotOffers(source);tradeOffers._srcId=tradeSourceId}
ob.innerHTML='';
tradeOffers.forEach((offer,index)=>{
const diff=offer.item.price-source.price;
const d=document.createElement('div');
d.className=`bot-offer rarity-${offer.item.rarity}`;
d.innerHTML=`<img src="${iconUrl(offer.item.icon)}"><div><div class="bot-name">${offer.bot}</div><div style="font-weight:bold;font-size:10px">${offer.item.name}</div><div class="bot-price">${offer.item.price} ₽</div><div style="font-size:9px;color:${diff>=0?'#7fff00':'#ef4444'}">${diff>=0?'+':''}${diff} ₽</div><div class="bot-comment">${offer.comment}</div></div><button class="trade-accept" onclick="acceptBotTrade(${index})">Принять</button>`;
ob.appendChild(d);
});
}
function selectTradeSource(id){SFX.click();tradeSourceId=id;tradeOffers=[];renderTradePanel()}
function acceptBotTrade(index){
const source=inventory.find(i=>i.id===tradeSourceId);
const offer=tradeOffers[index];
if(!source||!offer){notify('Трэйд сломался','#ef4444');return}
const profit=offer.item.price-source.price;
inventory=inventory.filter(i=>i.id!==source.id);
const newItem={...offer.item,id:Date.now()+Math.random()};
newItem.wear=rollWear();
newItem.stattrak=rollStattrak(offer.item.rarity==='halloween'||offer.item.rarity==='knife'?20:5);
inventory.push(newItem);
mcProfile.stats.tradesDone++;
mcProfile.stats.tradeProfit+=profit;
addMCXP(30);addBPXP(25);
completeQuest('doTrade',1);
saveMCProfile();
tradeSourceId=null;tradeOffers=[];
SFX.coin();
if(profit>=0){notify(`Трэйд: +${profit} ₽`,'#7fff00',offer.item.icon,randMeme(MEMES.knifeWin));if(profit>=500)showBigMeme('🤖','БОТ ПРОИГРАЛ!',randMeme(MEMES.knifeWin))}
else{notify(`Трэйд: ${profit} ₽`,'#ef4444',offer.item.icon,randMeme(MEMES.lose))}
renderInventory();renderTradePanel();renderUpgradePanels();renderProfile();
}

// ============ ПРОФИЛЬ ============
const AVATARS=['avatar_skuf','avatar_knife','avatar_case','avatar_pacman','avatar_crown','avatar_skull','avatar_pumpkin','avatar_ghost'];
const MC_RANKS=[
{xp:0,name:'Мусорный новичок',icon:'🗑️'},
{xp:100,name:'Тыква-новичок',icon:'🎃'},
{xp:300,name:'Скуф-трейдер',icon:'🧔'},
{xp:700,name:'Кейсоман',icon:'📦'},
{xp:1500,name:'Охотник за лимитками',icon:'💎'},
{xp:3000,name:'Легенда Хэллоуина',icon:'👻'},
{xp:6000,name:'MusorCase King',icon:'🎃'}
];

let mcProfile=JSON.parse(localStorage.getItem('mcProfile')||'null')||{
nick:'Мусорщик',xp:0,avatar:'avatar_pumpkin',
stats:{casesOpened:0,spent:0,wheelSpins:0,upgradesTried:0,tradesDone:0,tradeProfit:0,gamesPlayed:0}
};
function saveMCProfile(){localStorage.setItem('mcProfile',JSON.stringify(mcProfile))}
function getRankInfo(xp){
let current=MC_RANKS[0],next=null;
for(let i=0;i<MC_RANKS.length;i++){if(xp>=MC_RANKS[i].xp){current=MC_RANKS[i];next=MC_RANKS[i+1]||null}}
let progress=100;
if(next){progress=((xp-current.xp)/(next.xp-current.xp))*100;progress=Math.max(0,Math.min(100,progress))}
return{current,next,progress};
}
function addMCXP(amount){
const oldRank=getRankInfo(mcProfile.xp).current.name;
mcProfile.xp+=amount;
const newRank=getRankInfo(mcProfile.xp).current.name;
saveMCProfile();
if(oldRank!==newRank){SFX.win();showBigMeme('🏆','НОВЫЙ РАНГ!',newRank);notify(`Новый ранг: ${newRank}`,'#f97316')}
if(document.getElementById('section-profile').classList.contains('active'))renderProfile();
}

function renderProfile(){
const box=document.getElementById('profileContent');if(!box)return;
const rank=getRankInfo(mcProfile.xp);
const best=inventory.length?[...inventory].sort((a,b)=>b.price-a.price)[0]:null;
const invValue=inventory.reduce((s,i)=>s+i.price,0);
const halloweenCount=inventory.filter(i=>i.rarity==='halloween').length;
box.innerHTML=`<div class="profile-grid">
<div class="profile-box"><div class="label">Аватар</div><div class="avatar-grid">${AVATARS.map(a=>`<div class="avatar-item ${mcProfile.avatar===a?'selected':''}" onclick="selectAvatar('${a}')"><img src="${iconUrl(a)}"></div>`).join('')}</div></div>
<div class="profile-box"><div class="label">Ник</div><div class="value" style="font-size:13px">${mcProfile.nick}</div><button class="profile-btn" onclick="editNickname()">Сменить</button></div>
<div class="profile-box"><div class="label">Ранг</div><div class="rank-badge">${rank.current.icon} ${rank.current.name}</div><div style="margin-top:3px;color:#aaa;font-size:10px">XP: ${mcProfile.xp}</div><div class="rank-progress"><div class="rank-progress-fill" style="width:${rank.progress}%"></div></div><div style="font-size:9px;color:#aaa;margin-top:2px">${rank.next?`До след.: ${rank.next.xp-mcProfile.xp} XP`:'Макс. ранг'}</div></div>
<div class="profile-box"><div class="label">💰 Баланс</div><div class="value">${balance} ₽</div></div>
<div class="profile-box"><div class="label">💎 Алмазы</div><div class="value" style="color:#60a5fa">${diamonds}</div></div>
<div class="profile-box"><div class="label">Инвентарь</div><div class="value">${invValue} ₽</div></div>
<div class="profile-box"><div class="label">🎃 Лимиток</div><div class="value" style="color:#f97316">${halloweenCount}</div></div>
<div class="profile-box"><div class="label">Кейсов</div><div class="value">${mcProfile.stats.casesOpened}</div></div>
<div class="profile-box"><div class="label">Потрачено</div><div class="value">${mcProfile.stats.spent} ₽</div></div>
<div class="profile-box"><div class="label">Колесо</div><div class="value">${mcProfile.stats.wheelSpins}</div></div>
<div class="profile-box"><div class="label">Апгрейды</div><div class="value">${mcProfile.stats.upgradesTried}</div></div>
<div class="profile-box"><div class="label">Трейды</div><div class="value">${mcProfile.stats.tradesDone}</div></div>
<div class="profile-box"><div class="label">Профит трейдов</div><div class="value" style="color:${mcProfile.stats.tradeProfit>=0?'#7fff00':'#ef4444'}">${mcProfile.stats.tradeProfit>=0?'+':''}${mcProfile.stats.tradeProfit} ₽</div></div>
<div class="profile-box"><div class="label">Игры</div><div class="value">${mcProfile.stats.gamesPlayed}</div></div>
<div class="profile-box"><div class="label">Лучший дроп</div>${best?`<img src="${iconUrl(best.icon)}" style="width:55px;height:55px"><div class="value" style="font-size:11px">${best.name}</div><div style="color:#7fff00;font-weight:bold">${best.price} ₽</div>`:`<div class="value" style="font-size:11px;color:#aaa">Пока ничего</div>`}</div>
</div>`;
}
function selectAvatar(a){mcProfile.avatar=a;saveMCProfile();renderProfile();SFX.click()}
function editNickname(){
const nick=prompt('Введи новый ник:',mcProfile.nick);
if(!nick)return;
mcProfile.nick=nick.slice(0,20);
saveMCProfile();renderProfile();SFX.click();
}

// ============ ЕЖЕДНЕВНЫЕ НАГРАДЫ (С АЛМАЗАМИ) ============
const DAILY_REWARDS=[
{day:1,reward:100,type:'rub',label:'100 ₽'},
{day:2,reward:200,type:'rub',label:'200 ₽'},
{day:3,reward:350,type:'rub',label:'350 ₽'},
{day:4,reward:10,type:'diamond',label:'💎 10'},
{day:5,reward:750,type:'rub',label:'750 ₽'},
{day:6,reward:1500,type:'rub',label:'1500 ₽'},
{day:7,reward:50,type:'diamond',label:'💎 50'}
];
let dailyData=JSON.parse(localStorage.getItem('mcDaily')||'null')||{lastClaim:0,streak:0};
function saveDaily(){localStorage.setItem('mcDaily',JSON.stringify(dailyData))}

function renderDailyRewards(){
const grid=document.getElementById('dailyGrid');grid.innerHTML='';
const today=new Date().toDateString();
const lastDay=dailyData.lastClaim?new Date(dailyData.lastClaim).toDateString():'';
const canClaim=lastDay!==today;
DAILY_REWARDS.forEach((dr,i)=>{
const d=document.createElement('div');
let cls='daily-day';
if(i<dailyData.streak)cls+=' claimed';
else if(i===dailyData.streak&&canClaim)cls+=' today';
else if(i>dailyData.streak)cls+=' locked';
d.className=cls;
const rewardClass=dr.type==='diamond'?'day-reward diamond':'day-reward';
d.innerHTML=`<div class="day-num">День ${dr.day}</div><div class="${rewardClass}">${dr.label}</div>`;
grid.appendChild(d);
});
const btn=document.getElementById('claimDailyBtn');
btn.disabled=!canClaim||dailyData.streak>=7;
btn.textContent=canClaim?(dailyData.streak>=7?'🎉 Все получены':'🎁 Забрать'):'✅ Получено';
}
function claimDailyReward(){
const today=new Date().toDateString();
const lastDay=dailyData.lastClaim?new Date(dailyData.lastClaim).toDateString():'';
if(lastDay===today||dailyData.streak>=7)return;
const reward=DAILY_REWARDS[dailyData.streak];
if(reward.type==='diamond'){diamonds+=reward.reward;SFX.diamond();showBigMeme('💎',`+${reward.reward} алмазов!`,'Лимитки ждут!')}
else{balance+=reward.reward;SFX.coin()}
updateBalance();
dailyData.lastClaim=Date.now();
dailyData.streak++;
if(dailyData.streak>=7)dailyData.streak=0;
saveDaily();addBPXP(50);
notify(`🎁 День ${reward.day}: ${reward.label}`,'#f97316',null,'ИЗИ');
renderDailyRewards();
}

// ============ БАТЛ-ПАСС (С АЛМАЗАМИ) ============
let bpData=JSON.parse(localStorage.getItem('mcBP')||'null')||{xp:0,level:1,freeClaimed:[],premiumClaimed:[],quests:{}};
function saveBP(){localStorage.setItem('mcBP',JSON.stringify(bpData))}

const BP_QUESTS=[
{id:'openCases',name:'Открыть кейсы',target:20,reward:100,rewardType:'rub',xp:50},
{id:'getKnife',name:'Получить нож',target:1,reward:500,rewardType:'rub',xp:200},
{id:'getGloves',name:'Получить перчатки',target:1,reward:300,rewardType:'rub',xp:150},
{id:'getLegendary',name:'Легендарку',target:3,reward:200,rewardType:'rub',xp:100},
{id:'getHalloween',name:'🎃 Лимитку',target:1,reward:20,rewardType:'diamond',xp:300},
{id:'doUpgrade',name:'Апгрейд',target:5,reward:150,rewardType:'rub',xp:80},
{id:'doTrade',name:'Трейды',target:3,reward:150,rewardType:'rub',xp:80},
{id:'playGames',name:'Игры',target:10,reward:200,rewardType:'rub',xp:100}
];

const BP_REWARDS_FREE=[
{t:'rub',v:50},{t:'rub',v:100},{t:'rub',v:150},{t:'diamond',v:5},{t:'rub',v:250},
{t:'rub',v:300},{t:'diamond',v:10},{t:'rub',v:500},{t:'rub',v:600},{t:'diamond',v:15},
{t:'rub',v:900},{t:'rub',v:1000},{t:'diamond',v:20},{t:'rub',v:1500},{t:'rub',v:1800},
{t:'diamond',v:25},{t:'rub',v:2500},{t:'rub',v:3000},{t:'diamond',v:30},{t:'rub',v:4000},
{t:'rub',v:5000},{t:'diamond',v:40},{t:'rub',v:7500},{t:'rub',v:9000},{t:'diamond',v:50},
{t:'rub',v:10000},{t:'diamond',v:75},{t:'rub',v:15000},{t:'diamond',v:100},{t:'diamond',v:250}
];
const BP_REWARDS_PREMIUM=[
{t:'diamond',v:10},{t:'rub',v:300},{t:'diamond',v:15},{t:'rub',v:600},{t:'diamond',v:20},
{t:'rub',v:900},{t:'diamond',v:25},{t:'rub',v:1500},{t:'diamond',v:30},{t:'rub',v:2250},
{t:'diamond',v:40},{t:'rub',v:3000},{t:'diamond',v:50},{t:'rub',v:4500},{t:'diamond',v:60},
{t:'rub',v:6000},{t:'diamond',v:75},{t:'rub',v:9000},{t:'diamond',v:100},{t:'rub',v:12000},
{t:'diamond',v:125},{t:'rub',v:18000},{t:'diamond',v:150},{t:'rub',v:27000},{t:'diamond',v:200},
{t:'rub',v:30000},{t:'diamond',v:250},{t:'rub',v:60000},{t:'diamond',v:350},{t:'diamond',v:500}
];

function addBPXP(amount){
bpData.xp+=amount;
const newLevel=Math.floor(bpData.xp/100)+1;
if(newLevel>bpData.level){bpData.level=newLevel;SFX.win();notify(`🎫 Уровень БП: ${bpData.level}`,'#f97316')}
saveBP();
if(document.getElementById('section-battlepass').classList.contains('active'))renderBattlePass();
}

function completeQuest(id,amount){
if(!bpData.quests[id])bpData.quests[id]={progress:0};
const q=BP_QUESTS.find(x=>x.id===id);
if(!q||bpData.quests[id].claimed)return;
bpData.quests[id].progress=Math.min(q.target,bpData.quests[id].progress+amount);
if(bpData.quests[id].progress>=q.target&&!bpData.quests[id].claimed){
bpData.quests[id].claimed=true;
if(q.rewardType==='diamond'){diamonds+=q.reward;SFX.diamond()}
else{balance+=q.reward}
updateBalance();
addBPXP(q.xp);
notify(`📋 Задание: +${q.reward} ${q.rewardType==='diamond'?'💎':'₽'}`,'#f97316');
}
saveBP();
}

function renderBattlePass(){
document.getElementById('bpLevel').textContent=bpData.level;
document.getElementById('bpXP').textContent=bpData.xp;
document.getElementById('bpNextXP').textContent=bpData.level*100;
document.getElementById('bpProgressFill').style.width=(bpData.xp%100)+'%';
const freeTrack=document.getElementById('bpFreeTrack');
const premTrack=document.getElementById('bpPremiumTrack');
freeTrack.innerHTML='';premTrack.innerHTML='';
for(let i=1;i<=30;i++){
const unlocked=bpData.level>=i;
const freeClaimed=bpData.freeClaimed.includes(i);
const premClaimed=bpData.premiumClaimed.includes(i);
const fr=BP_REWARDS_FREE[i-1];
const pr=BP_REWARDS_PREMIUM[i-1];
const freeDiv=document.createElement('div');
freeDiv.className='bp-level'+(unlocked?' unlocked':'')+(freeClaimed?' claimed':'');
const freeLabel=fr.t==='diamond'?`💎 ${fr.v}`:`💰 ${fr.v} ₽`;
freeDiv.innerHTML=`<div class="lvl-num">${i}</div><div class="lvl-reward">${freeLabel}</div>${unlocked&&!freeClaimed?`<button class="claim-btn" onclick="claimBP('free',${i})">Забрать</button>`:freeClaimed?'<span style="color:#f97316">✓</span>':'<span style="color:#666">🔒</span>'}`;
freeTrack.appendChild(freeDiv);
const premDiv=document.createElement('div');
premDiv.className='bp-level'+(unlocked?' unlocked':'')+(premClaimed?' claimed':'');
const premLabel=pr.t==='diamond'?`💎 ${pr.v}`:`💰 ${pr.v} ₽`;
premDiv.innerHTML=`<div class="lvl-num">${i}</div><div class="lvl-reward">${premLabel}</div>${unlocked&&!premClaimed?`<button class="claim-btn" onclick="claimBP('premium',${i})">Забрать</button>`:premClaimed?'<span style="color:#f97316">✓</span>':'<span style="color:#666">🔒</span>'}`;
premTrack.appendChild(premDiv);
}
const questsDiv=document.getElementById('bpQuests');questsDiv.innerHTML='';
BP_QUESTS.forEach(q=>{
const prog=bpData.quests[q.id]||{progress:0,claimed:false};
const pct=Math.min(100,(prog.progress/q.target)*100);
const d=document.createElement('div');
d.className='quest'+(prog.claimed?' completed':'');
const rewardLabel=q.rewardType==='diamond'?`💎 ${q.reward}`:`+${q.reward} ₽`;
d.innerHTML=`<div class="q-name">${q.name}</div><div class="q-progress"><div class="q-progress-fill" style="width:${pct}%"></div></div><div class="q-info"><span>${prog.progress} / ${q.target}</span><span class="q-reward">${rewardLabel} | +${q.xp} XP</span></div>`;
questsDiv.appendChild(d);
});
}
function claimBP(type,level){
if(bpData.level<level)return;
const rewards=type==='free'?BP_REWARDS_FREE:BP_REWARDS_PREMIUM;
const claimed=type==='free'?bpData.freeClaimed:bpData.premiumClaimed;
if(claimed.includes(level))return;
claimed.push(level);
const r=rewards[level-1];
if(r.t==='diamond'){diamonds+=r.v;SFX.diamond()}else{balance+=r.v}
updateBalance();saveBP();SFX.coin();notify(`🎫 Награда БП!`,'#f97316');renderBattlePass();
}

// ============ GEOMETRY DASH ============
const gdCanvas=document.getElementById('gdCanvas'),gdCtx=gdCanvas.getContext('2d');
let gd={running:false,cube:{x:100,y:200,size:40,vy:0,rot:0,onG:true},obstacles:[],particles:[],dist:0,speed:6,base:6,grav:.8,jp:-14,gY:260,rec:parseInt(localStorage.getItem('gdRec')||'0'),aid:null,rew:0,lrd:0,bgo:0,gro:0};
document.getElementById('gdRecord').textContent=gd.rec;

function startGame(g){
SFX.click();
document.getElementById('gamesGrid').style.display='none';
document.getElementById('gameArea-'+g).classList.add('active');
mcProfile.stats.gamesPlayed++;
addMCXP(5);addBPXP(5);
completeQuest('playGames',1);
saveMCProfile();
if(g==='gd')initGD();else if(g==='pacman')initPacman();else if(g==='crash')initCrash();
}
function exitGame(g){
SFX.click();
if(g==='gd'){gd.running=false;if(gd.aid)cancelAnimationFrame(gd.aid)}
else if(g==='pacman'){pm.running=false;if(pm.aid)cancelAnimationFrame(pm.aid)}
else if(g==='crash'){crash.running=false;if(crash.aid)cancelAnimationFrame(crash.aid)}
document.getElementById('gamesGrid').style.display='grid';
document.getElementById('gameArea-'+g).classList.remove('active');
const goId=g==='gd'?'gdGameOver':g==='pacman'?'pmGameOver':null;
if(goId)document.getElementById(goId).classList.remove('active');
}
function initGD(){
gd.cube={x:100,y:200,size:40,vy:0,rot:0,onG:true};
gd.obstacles=[];gd.particles=[];gd.dist=0;gd.speed=6;
gd.rew=0;gd.lrd=0;gd.bgo=0;gd.gro=0;
document.getElementById('gdGameOver').classList.remove('active');
gd.running=true;gdLoop();
}
function restartGD(){initGD()}
function gdJump(){
if(!gd.running||!gd.cube.onG)return;
gd.cube.vy=gd.jp;gd.cube.onG=false;SFX.jump();
for(let i=0;i<6;i++)gd.particles.push({x:gd.cube.x+gd.cube.size/2,y:gd.cube.y+gd.cube.size,vx:(Math.random()-.5)*4,vy:Math.random()*3,life:20,color:'#f97316',size:3+Math.random()*3});
}
function spawnObs(){
const t=['spike','spike','spike','block','doubleSpike'][Math.floor(Math.random()*5)];
let w,h,y;
if(t==='spike'){w=30;h=40;y=gd.gY-h}
else if(t==='doubleSpike'){w=60;h=40;y=gd.gY-h}
else{w=40;h=40;y=Math.random()<.5?gd.gY-h:gd.gY-h-70}
gd.obstacles.push({t,x:850,y,w,h});
}
function chkCol(c,o){
if(o.t==='spike'||o.t==='doubleSpike'){
const cx=c.x+c.size/2,cy=c.y+c.size/2,r=c.size*.4;
return cx+r>o.x&&cx-r<o.x+o.w&&cy+r>o.y&&cy-r<o.y+o.h&&cy+r>o.y+o.h*.4;
}
return c.x<o.x+o.w&&c.x+c.size>o.x&&c.y<o.y+o.h&&c.y+c.size>o.y;
}
function gdLoop(){
if(!gd.running)return;
gd.cube.vy+=gd.grav;gd.cube.y+=gd.cube.vy;
if(gd.cube.y+gd.cube.size>=gd.gY){gd.cube.y=gd.gY-gd.cube.size;gd.cube.vy=0;gd.cube.onG=true}
if(!gd.cube.onG)gd.cube.rot+=.15;
else{const t=Math.round(gd.cube.rot/(Math.PI/2))*(Math.PI/2);gd.cube.rot+=(t-gd.cube.rot)*.3}
gd.dist+=gd.speed*.1;gd.speed=gd.base+gd.dist*.005;if(gd.speed>14)gd.speed=14;
const m=Math.floor(gd.dist),rt=Math.floor(m/10);
if(rt>gd.lrd){gd.rew+=rt-gd.lrd;gd.lrd=rt}
const mg=Math.max(180,300-gd.dist*.3);
if(gd.obstacles.length===0||(800-gd.obstacles[gd.obstacles.length-1].x)>mg+Math.random()*150)spawnObs();
gd.obstacles.forEach(o=>o.x-=gd.speed);
gd.obstacles=gd.obstacles.filter(o=>o.x+o.w>-50);
for(const o of gd.obstacles)if(chkCol(gd.cube,o)){gameOverGD();return}
gd.particles.forEach(p=>{p.x+=p.vx;p.y+=p.vy;p.vy+=.2;p.life--});
gd.particles=gd.particles.filter(p=>p.life>0);
gd.bgo=(gd.bgo+gd.speed*.3)%100;gd.gro=(gd.gro+gd.speed)%40;
drawGD();
document.getElementById('gdDistance').textContent=Math.floor(gd.dist);
document.getElementById('gdReward').textContent=gd.rew;
gd.aid=requestAnimationFrame(gdLoop);
}
function drawGD(){
gdCtx.clearRect(0,0,800,300);
const bg=gdCtx.createLinearGradient(0,0,0,300);
bg.addColorStop(0,'#1a0a1f');bg.addColorStop(.5,'#0a0a0f');bg.addColorStop(1,'#0a0a0f');
gdCtx.fillStyle=bg;gdCtx.fillRect(0,0,800,300);
gdCtx.fillStyle='rgba(249,115,22,.2)';
for(let i=0;i<30;i++){const x=(i*73-gd.bgo)%800,y=(i*37)%200;gdCtx.fillRect(x<0?x+800:x,y,2,2)}
gdCtx.fillStyle='#1f2937';gdCtx.fillRect(0,gd.gY,800,40);
gdCtx.strokeStyle='#7c2d12';gdCtx.lineWidth=2;
for(let x=-gd.gro;x<800;x+=40){gdCtx.beginPath();gdCtx.moveTo(x,gd.gY);gdCtx.lineTo(x+20,gd.gY+40);gdCtx.stroke()}
gdCtx.strokeStyle='#f97316';gdCtx.lineWidth=3;
gdCtx.beginPath();gdCtx.moveTo(0,gd.gY);gdCtx.lineTo(800,gd.gY);gdCtx.stroke();
gd.obstacles.forEach(o=>{
if(o.t==='spike'){drawSpike(o.x,o.y,o.w,o.h)}
else if(o.t==='doubleSpike'){drawSpike(o.x,o.y,30,o.h);drawSpike(o.x+30,o.y,30,o.h)}
else{
const g=gdCtx.createLinearGradient(o.x,o.y,o.x,o.y+o.h);
g.addColorStop(0,'#f97316');g.addColorStop(1,'#7c2d12');
gdCtx.fillStyle=g;gdCtx.fillRect(o.x,o.y,o.w,o.h);
gdCtx.strokeStyle='#fbbf24';gdCtx.lineWidth=2;gdCtx.strokeRect(o.x,o.y,o.w,o.h);
}
});
gd.particles.forEach(p=>{gdCtx.fillStyle=p.color;gdCtx.globalAlpha=p.life/20;gdCtx.fillRect(p.x,p.y,p.size,p.size)});
gdCtx.globalAlpha=1;
gdCtx.save();gdCtx.translate(gd.cube.x+gd.cube.size/2,gd.cube.y+gd.cube.size/2);gdCtx.rotate(gd.cube.rot);
const cg=gdCtx.createLinearGradient(-20,-20,20,20);cg.addColorStop(0,'#f97316');cg.addColorStop(1,'#7c2d12');
gdCtx.fillStyle=cg;gdCtx.fillRect(-gd.cube.size/2,-gd.cube.size/2,gd.cube.size,gd.cube.size);
gdCtx.strokeStyle='#fbbf24';gdCtx.lineWidth=3;gdCtx.strokeRect(-gd.cube.size/2,-gd.cube.size/2,gd.cube.size,gd.cube.size);
gdCtx.fillStyle='#fbbf24';gdCtx.fillRect(-5,-8,14,14);
gdCtx.fillStyle='#000';gdCtx.fillRect(2,-5,7,8);gdCtx.restore();
}
function drawSpike(x,y,w,h){
const g=gdCtx.createLinearGradient(x,y,x,y+h);g.addColorStop(0,'#fbbf24');g.addColorStop(1,'#7c2d12');
gdCtx.fillStyle=g;gdCtx.beginPath();gdCtx.moveTo(x+w/2,y);gdCtx.lineTo(x,y+h);gdCtx.lineTo(x+w,y+h);gdCtx.closePath();
gdCtx.fill();gdCtx.strokeStyle='#f97316';gdCtx.lineWidth=2;gdCtx.stroke();
}
function gameOverGD(){
gd.running=false;if(gd.aid)cancelAnimationFrame(gd.aid);SFX.die();
const fd=Math.floor(gd.dist);
if(fd>gd.rec){gd.rec=fd;localStorage.setItem('gdRec',gd.rec);document.getElementById('gdRecord').textContent=gd.rec;notify(`🏆 Рекорд: ${gd.rec} м!`,'#f97316')}
balance+=gd.rew;updateBalance();
document.getElementById('gdFinalDist').textContent=fd;
document.getElementById('gdFinalReward').textContent=gd.rew;
document.getElementById('gdMeme').textContent=randMeme(MEMES.gdDeath);
document.getElementById('gdGameOver').classList.add('active');
if(gd.rew>0)notify(`💰 +${gd.rew} ₽`,'#7fff00',null,randMeme(MEMES.epicWin));
}
document.addEventListener('keydown',e=>{if(e.code==='Space'&&gd.running){e.preventDefault();gdJump()}});
gdCanvas.addEventListener('mousedown',gdJump);
gdCanvas.addEventListener('touchstart',e=>{e.preventDefault();gdJump()});

// ============ PAC-MAN ============
const pmCanvas=document.getElementById('pacmanCanvas'),pmCtx=pmCanvas.getContext('2d');
const PM_CELL=16;
const PM_MAP=[
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,1],
[1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1],
[1,3,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,3,1],
[1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1],
[1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1],
[1,2,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2,1],
[1,2,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,2,1],
[1,2,2,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,1],
[1,1,1,1,1,1,2,1,1,1,1,1,0,1,1,0,1,1,1,1,1,2,1,1,1,1,1,1],
[0,0,0,0,0,1,2,1,1,1,1,1,0,1,1,0,1,1,1,1,1,2,1,0,0,0,0,0],
[0,0,0,0,0,1,2,1,1,0,0,0,0,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0],
[0,0,0,0,0,1,2,1,1,0,1,1,1,0,0,1,1,1,0,1,1,2,1,0,0,0,0,0],
[1,1,1,1,1,1,2,1,1,0,1,0,0,0,0,0,0,1,0,1,1,2,1,1,1,1,1,1],
[0,0,0,0,0,0,2,0,0,0,1,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0],
[1,1,1,1,1,1,2,1,1,0,1,0,0,0,0,0,0,1,0,1,1,2,1,1,1,1,1,1],
[0,0,0,0,0,1,2,1,1,0,1,1,1,1,1,1,1,1,0,1,1,2,1,0,0,0,0,0],
[0,0,0,0,0,1,2,1,1,0,0,0,0,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0],
[0,0,0,0,0,1,2,1,1,0,1,1,1,1,1,1,1,1,0,1,1,2,1,0,0,0,0,0],
[1,1,1,1,1,1,2,1,1,0,1,1,1,1,1,1,1,1,0,1,1,2,1,1,1,1,1,1],
[1,2,2,2,2,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,1],
[1,2,1,1,1,1,2,1,1,1,1,1,2,1,1,2,1,1,1,1,1,2,1,1,1,1,2,1],
[1,3,2,2,1,1,2,2,2,2,2,2,2,0,0,2,2,2,2,2,2,2,1,1,2,2,3,1],
[1,1,1,2,1,1,2,1,1,2,1,1,1,1,1,1,1,1,2,1,1,2,1,1,2,1,1,1],
[1,2,2,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,1],
[1,2,1,1,1,1,1,1,1,1,1,1,2,1,1,2,1,1,1,1,1,1,1,1,1,1,2,1],
[1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];
const PM_W=28,PM_H=28;
let pm={running:false,pac:{x:13.5,y:22.5,dir:0,nextDir:0,mouth:0,mouthOpen:true},ghosts:[],map:[],score:0,lives:3,rew:0,rec:parseInt(localStorage.getItem('pmRec')||'0'),aid:null,pellets:0,powerTimer:0};

function initPacman(){
pm.map=PM_MAP.map(r=>[...r]);
pm.pac={x:13.5,y:22.5,dir:0,nextDir:0,mouth:0,mouthOpen:true};
pm.ghosts=[
{x:13.5,y:11.5,dir:2,color:'#f97316',mode:'chase',startX:13.5,startY:11.5,name:'Pumpkin'},
{x:12.5,y:13.5,dir:2,color:'#a855f7',mode:'chase',startX:12.5,startY:13.5,name:'Ghost'},
{x:14.5,y:13.5,dir:2,color:'#10b981',mode:'chase',startX:14.5,startY:13.5,name:'Spider'},
{x:13.5,y:13.5,dir:2,color:'#dc2626',mode:'chase',startX:13.5,startY:13.5,name:'Blood'}
];
pm.score=0;pm.lives=3;pm.rew=0;pm.powerTimer=0;pm.pellets=0;
for(let y=0;y<PM_H;y++)for(let x=0;x<PM_W;x++)if(pm.map[y][x]===2||pm.map[y][x]===3)pm.pellets++;
document.getElementById('pmGameOver').classList.remove('active');
pm.running=true;pmLoop();
}
function restartPacman(){initPacman()}

function pmCanMove(x,y,dir){
const dx=[1,0,-1,0][dir],dy=[0,1,0,-1][dir];
const nx=Math.floor(x+dx*0.6),ny=Math.floor(y+dy*0.6);
if(ny===13&&(nx<0||nx>=PM_W))return true;
if(nx<0||nx>=PM_W||ny<0||ny>=PM_H)return false;
return pm.map[ny][nx]!==1;
}

function pmLoop(){
if(!pm.running)return;
const p=pm.pac,spd=0.08;
const dx=[1,0,-1,0][p.dir],dy=[0,1,0,-1][p.dir];
let nx=p.x+dx*spd,ny=p.y+dy*spd;
if(pmCanMove(nx,ny,p.dir)){p.x=nx;p.y=ny}
else{p.x=Math.round(p.x-0.5)+0.5;p.y=Math.round(p.y-0.5)+0.5}
const cx=Math.round(p.x-0.5)+0.5,cy=Math.round(p.y-0.5)+0.5;
if(Math.abs(p.x-cx)+Math.abs(p.y-cy)<0.05&&p.nextDir!==p.dir&&p.nextDir!==4&&pmCanMove(cx,cy,p.nextDir)){p.dir=p.nextDir;p.x=cx;p.y=cy}
if(p.mouthOpen){p.mouth+=0.15;if(p.mouth>=0.8)p.mouthOpen=false}else{p.mouth-=0.15;if(p.mouth<=0)p.mouthOpen=true}
const tx=Math.floor(p.x),ty=Math.floor(p.y);
if(tx>=0&&tx<PM_W&&ty>=0&&ty<PM_H){
if(pm.map[ty][tx]===2){pm.map[ty][tx]=0;pm.score+=10;pm.pellets--;SFX.coin()}
else if(pm.map[ty][tx]===3){pm.map[ty][tx]=0;pm.score+=50;pm.pellets--;pm.powerTimer=400;SFX.powerup()}
}
const newRew=Math.floor(pm.score/10);if(newRew>pm.rew)pm.rew=newRew;
if(pm.powerTimer>0)pm.powerTimer--;
pm.ghosts.forEach(g=>{
const gspd=0.06,gdx=[1,0,-1,0][g.dir],gdy=[0,1,0,-1][g.dir];
let gnx=g.x+gdx*gspd,gny=g.y+gdy*gspd;
const gcx=Math.floor(gnx+(gdx>0?.4:gdx<0?-.4:0)),gcy=Math.floor(gny+(gdy>0?.4:gdy<0?-.4:0));
if(gcx<0||gcx>=PM_W){gnx=gnx<0?PM_W-1:0}
else if(gcy<0||gcy>=PM_H||pm.map[gcy][gcx]===1){
const possible=[];
for(let d=0;d<4;d++){
if(d===(g.dir+2)%4)continue;
const ddx=[1,0,-1,0][d],ddy=[0,1,0,-1][d];
const tcx=Math.floor(g.x+ddx),tcy=Math.floor(g.y+ddy);
if(tcx<0||tcx>=PM_W){if(tcy===13)possible.push(d)}
else if(tcy>=0&&tcy<PM_H&&pm.map[tcy][tcx]!==1)possible.push(d);
}
if(possible.length>0){
if(g.mode==='frightened')g.dir=possible[Math.floor(Math.random()*possible.length)];
else{let best=possible[0],bestD=Infinity;possible.forEach(d=>{const ddx=[1,0,-1,0][d],ddy=[0,1,0,-1][d];const dist=Math.abs(g.x+ddx-p.x)+Math.abs(g.y+ddy-p.y);if(dist<bestD){bestD=dist;best=d}});g.dir=best}
gnx=g.x;gny=g.y;
}
}
g.x=gnx;g.y=gny;
if(Math.abs(g.x-p.x)<0.7&&Math.abs(g.y-p.y)<0.7){
if(g.mode==='frightened'){g.x=g.startX;g.y=g.startY;g.mode='chase';pm.score+=200;SFX.powerup()}
else{pm.lives--;SFX.die();if(pm.lives<=0){gameOverPM();return}p.x=13.5;p.y=22.5;p.dir=0;p.nextDir=0;pm.ghosts.forEach(gg=>{gg.x=gg.startX;gg.y=gg.startY;gg.mode='chase'})}
}
if(pm.powerTimer>0&&g.mode!=='frightened')g.mode='frightened';
if(pm.powerTimer===0&&g.mode==='frightened')g.mode='chase';
});
drawPM();
document.getElementById('pmScore').textContent=pm.score;
document.getElementById('pmReward').textContent=pm.rew;
document.getElementById('pmLives').textContent=pm.lives;
if(pm.pellets===0){notify('🎃 Уровень пройден!','#f97316',null,'ИЗИ');pm.running=false;setTimeout(()=>{initPacman();pm.score+=1000},1500);return}
pm.aid=requestAnimationFrame(pmLoop);
}
function drawPM(){
pmCtx.fillStyle='#0a0a0f';pmCtx.fillRect(0,0,448,496);
for(let y=0;y<PM_H;y++)for(let x=0;x<PM_W;x++){
const c=pm.map[y][x];
if(c===1){pmCtx.fillStyle='#7c2d12';pmCtx.fillRect(x*PM_CELL,y*PM_CELL,PM_CELL,PM_CELL);pmCtx.strokeStyle='#f97316';pmCtx.lineWidth=1;pmCtx.strokeRect(x*PM_CELL+.5,y*PM_CELL+.5,PM_CELL-1,PM_CELL-1)}
else if(c===2){pmCtx.fillStyle='#fbbf24';pmCtx.beginPath();pmCtx.arc(x*PM_CELL+PM_CELL/2,y*PM_CELL+PM_CELL/2,2.5,0,Math.PI*2);pmCtx.fill()}
else if(c===3){pmCtx.fillStyle='#f97316';pmCtx.shadowColor='#f97316';pmCtx.shadowBlur=10;pmCtx.beginPath();pmCtx.arc(x*PM_CELL+PM_CELL/2,y*PM_CELL+PM_CELL/2,6,0,Math.PI*2);pmCtx.fill();pmCtx.shadowBlur=0}
}
const p=pm.pac,px=p.x*PM_CELL+PM_CELL/2,py=p.y*PM_CELL+PM_CELL/2;
const angles=[0,Math.PI/2,Math.PI,-Math.PI/2],a=angles[p.dir];
pmCtx.save();pmCtx.translate(px,py);pmCtx.rotate(a);
pmCtx.shadowColor='#f97316';pmCtx.shadowBlur=15;pmCtx.fillStyle='#f97316';
pmCtx.beginPath();pmCtx.arc(0,0,PM_CELL*0.75,p.mouth,Math.PI*2-p.mouth);pmCtx.lineTo(0,0);pmCtx.fill();
pmCtx.shadowBlur=0;pmCtx.fillStyle='#1f2937';pmCtx.beginPath();pmCtx.arc(2,-6,3,0,Math.PI*2);pmCtx.fill();
pmCtx.fillStyle='#fbbf24';pmCtx.beginPath();pmCtx.arc(3,-7,1,0,Math.PI*2);pmCtx.fill();
pmCtx.restore();
pm.ghosts.forEach(g=>{
const gx=g.x*PM_CELL+PM_CELL/2,gy=g.y*PM_CELL+PM_CELL/2;
const isFrightened=g.mode==='frightened';
const color=isFrightened?(pm.powerTimer<100&&Math.floor(pm.powerTimer/10)%2===0?'#fff':'#581c87'):g.color;
pmCtx.save();pmCtx.translate(gx,gy);
pmCtx.fillStyle=color;pmCtx.beginPath();pmCtx.arc(0,-2,PM_CELL*0.7,Math.PI,0);pmCtx.lineTo(PM_CELL*0.7,PM_CELL*0.6);
for(let i=0;i<3;i++){pmCtx.lineTo(PM_CELL*0.7-i*PM_CELL*0.47-PM_CELL*0.12,PM_CELL*0.3);pmCtx.lineTo(PM_CELL*0.7-i*PM_CELL*0.47-PM_CELL*0.24,PM_CELL*0.6)}
pmCtx.lineTo(-PM_CELL*0.7,PM_CELL*0.6);pmCtx.closePath();pmCtx.fill();
if(isFrightened){
pmCtx.fillStyle='#fff';pmCtx.beginPath();pmCtx.arc(-4,-3,2.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(4,-3,2.5,0,Math.PI*2);pmCtx.fill();
pmCtx.fillStyle='#581c87';pmCtx.beginPath();pmCtx.arc(-4,-3,1,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(4,-3,1,0,Math.PI*2);pmCtx.fill();
}else{
pmCtx.fillStyle='#fff';pmCtx.beginPath();pmCtx.arc(-4,-3,3.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(4,-3,3.5,0,Math.PI*2);pmCtx.fill();
pmCtx.fillStyle='#1f2937';
if(g.name==='Pumpkin'){pmCtx.beginPath();pmCtx.arc(-3,-3,1.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(5,-3,1.5,0,Math.PI*2);pmCtx.fill()}
else if(g.name==='Ghost'){pmCtx.beginPath();pmCtx.arc(-4,-3,1.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(4,-3,1.5,0,Math.PI*2);pmCtx.fill()}
else if(g.name==='Spider'){pmCtx.beginPath();pmCtx.arc(-5,-3,1.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(5,-3,1.5,0,Math.PI*2);pmCtx.fill()}
else{pmCtx.beginPath();pmCtx.arc(-4,-2,1.5,0,Math.PI*2);pmCtx.fill();pmCtx.beginPath();pmCtx.arc(4,-2,1.5,0,Math.PI*2);pmCtx.fill()}
}
pmCtx.restore();
});
}
function gameOverPM(){
pm.running=false;if(pm.aid)cancelAnimationFrame(pm.aid);SFX.die();
if(pm.score>pm.rec){pm.rec=pm.score;localStorage.setItem('pmRec',pm.rec);notify(`🏆 Рекорд: ${pm.rec}`,'#f97316')}
balance+=pm.rew;updateBalance();
document.getElementById('pmFinalScore').textContent=pm.score;
document.getElementById('pmFinalReward').textContent=pm.rew;
document.getElementById('pmMeme').textContent=randMeme(MEMES.pmDeath);
document.getElementById('pmGameOver').classList.add('active');
if(pm.rew>0)notify(`💰 +${pm.rew} ₽`,'#7fff00',null,randMeme(MEMES.epicWin));
}
document.addEventListener('keydown',e=>{
if(['ArrowUp','ArrowDown','ArrowLeft','ArrowRight',' '].includes(e.key))e.preventDefault();
if(!pm.running)return;
const k=e.key.toLowerCase();
if(k==='arrowup'||k==='w'||k==='ц'){pm.pac.nextDir=3;SFX.click()}
else if(k==='arrowdown'||k==='s'||k==='ы'){pm.pac.nextDir=1;SFX.click()}
else if(k==='arrowleft'||k==='a'||k==='ф'){pm.pac.nextDir=2;SFX.click()}
else if(k==='arrowright'||k==='d'||k==='в'){pm.pac.nextDir=0;SFX.click()}
});

// ============ CRASH ============
const crashCanvas=document.getElementById('crashCanvas'),crashCtx=crashCanvas.getContext('2d');
let crash={running:false,bet:0,mult:1,crashAt:0,startTime:0,aid:null,cashedOut:false};

function initCrash(){
crash.running=false;crash.mult=1;crash.cashedOut=false;
document.getElementById('crashMult').textContent='1.00';
document.getElementById('crashWin').textContent='0';
document.getElementById('crashStartBtn').disabled=false;
document.getElementById('crashCashoutBtn').disabled=true;
document.getElementById('crashStatus').textContent='Сделай ставку и нажми СТАРТ';
drawCrash();
}
function startCrash(){
const bet=parseInt(document.getElementById('crashBet').value)||0;
if(bet<10){notify('❌ Минимум 10 ₽','#ff4444');return}
if(balance<bet){notify('❌ Недостаточно средств','#ff4444');return}
balance-=bet;updateBalance();
crash.bet=bet;crash.mult=1;crash.cashedOut=false;
const r=Math.random();
if(r<0.33)crash.crashAt=1+Math.random()*0.5;
else if(r<0.66)crash.crashAt=1.5+Math.random()*1.5;
else if(r<0.9)crash.crashAt=3+Math.random()*4;
else crash.crashAt=7+Math.random()*13;
crash.startTime=Date.now();
crash.running=true;
document.getElementById('crashStartBtn').disabled=true;
document.getElementById('crashCashoutBtn').disabled=false;
document.getElementById('crashStatus').textContent='📈 РАСТЁТ! Успей забрать!';
crashLoop();
}
function cashoutCrash(){
if(!crash.running||crash.cashedOut)return;
crash.cashedOut=true;
const win=Math.floor(crash.bet*crash.mult);
balance+=win;updateBalance();
SFX.win();
notify(`💰 Забрал ${win} ₽ (${crash.mult.toFixed(2)}x)`,'#7fff00');
document.getElementById('crashStatus').textContent=`✅ Забрано на ${crash.mult.toFixed(2)}x`;
document.getElementById('crashCashoutBtn').disabled=true;
}
function crashLoop(){
if(!crash.running)return;
const elapsed=(Date.now()-crash.startTime)/1000;
crash.mult=1+elapsed*0.3+Math.pow(elapsed/5,2);
if(crash.mult>=crash.crashAt&&!crash.cashedOut){
crash.running=false;SFX.crash();
document.getElementById('crashStatus').textContent=`💥 КРАХ на ${crash.crashAt.toFixed(2)}x! Потерял ${crash.bet} ₽`;
document.getElementById('crashStartBtn').disabled=false;
document.getElementById('crashCashoutBtn').disabled=true;
notify(`💥 Крах на ${crash.crashAt.toFixed(2)}x!`,'#ef4444',null,randMeme(MEMES.lose));
drawCrash(true);
return;
}
if(crash.cashedOut&&crash.mult>=crash.crashAt){
crash.running=false;
document.getElementById('crashStartBtn').disabled=false;
drawCrash();
return;
}
document.getElementById('crashMult').textContent=crash.mult.toFixed(2);
document.getElementById('crashWin').textContent=Math.floor(crash.bet*crash.mult);
if(Math.floor(elapsed*10)%3===0)SFX.crashTick();
drawCrash();
crash.aid=requestAnimationFrame(crashLoop);
}
function drawCrash(crashed=false){
const w=crashCanvas.width,h=crashCanvas.height;
crashCtx.clearRect(0,0,w,h);
const bg=crashCtx.createLinearGradient(0,0,0,h);
bg.addColorStop(0,'#0a0a0f');bg.addColorStop(1,'#1a0a1f');
crashCtx.fillStyle=bg;crashCtx.fillRect(0,0,w,h);
crashCtx.strokeStyle='rgba(249,115,22,0.1)';crashCtx.lineWidth=1;
for(let i=0;i<10;i++){crashCtx.beginPath();crashCtx.moveTo(0,i*h/10);crashCtx.lineTo(w,i*h/10);crashCtx.stroke()}
for(let i=0;i<10;i++){crashCtx.beginPath();crashCtx.moveTo(i*w/10,0);crashCtx.lineTo(i*w/10,h);crashCtx.stroke()}
if(crash.mult>1){
crashCtx.strokeStyle=crashed?'#ef4444':'#f97316';
crashCtx.lineWidth=4;crashCtx.beginPath();
const steps=100;
const maxY=Math.max(crash.mult,2);
for(let i=0;i<=steps;i++){
const t=i/steps;
const m=1+t*0.3*(crash.mult-1)+Math.pow(t,2)*(crash.mult-1);
const x=t*w*0.9+w*0.05;
const y=h-(m-1)/(maxY-1)*h*0.8-h*0.1;
if(i===0)crashCtx.moveTo(x,y);else crashCtx.lineTo(x,y);
}
crashCtx.stroke();
crashCtx.fillStyle=crashed?'#ef4444':'#f97316';
crashCtx.font='bold 40px Arial';
crashCtx.textAlign='center';
crashCtx.fillText(crash.mult.toFixed(2)+'x',w/2,h/2);
if(crashed){
crashCtx.fillStyle='#ef4444';
crashCtx.font='bold 30px Arial';
crashCtx.fillText('💥 CRASH!',w/2,h/2+40);
}
}
}

// ============ ИНИЦИАЛИЗАЦИЯ ============
renderCases();
updateBalance();
renderInventory();
renderUpgradePanels();
renderProfile();
renderTradePanel();
renderDailyRewards();
renderBattlePass();
initCrash();
document.addEventListener('click',()=>initAudio(),{once:true});
</script>
</body>
</html>