:root {
    --primary: #8183ff;
    --secondary: #f472b6;
    --accent: #fbbf24;
    --background: #0f172a;
    --surface: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --glass-border: rgba(255, 255, 255, 0.15);
    --hp-color: #f87171;
    --xp-color: #34d399;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    --glow: 0 0 20px rgba(129, 131, 255, 0.3);
}

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

body {
    background-color: var(--background);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    box-shadow: var(--shadow);
}

/* HUD Improvement */
#hud {
    position: absolute;
    top: 25px;
    left: 25px;
    right: 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.5s;
}

#hud.hidden { opacity: 0; }

.player-hud-top {
    display: flex;
    align-items: center;
    gap: 15px;
}

.portrait {
    width: 70px;
    height: 70px;
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(129, 131, 255, 0.5);
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.eye-box {
    width: 60%;
    height: 40%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.player-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
    padding: 12px;
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

.bar-container { width: 100%; height: 12px; background: rgba(0,0,0,0.4); border-radius: 6px; overflow: hidden; margin-top: 5px; }
.bar { height: 100%; width: 100%; transition: width 0.3s ease; }
.hp { background: linear-gradient(90deg, #ef4444, #b91c1c); box-shadow: 0 0 15px rgba(239, 68, 68, 0.5); }
.ult { background: linear-gradient(90deg, #fbbf24, #a855f7); box-shadow: 0 0 15px rgba(168, 85, 247, 0.5); width: 0%; }
.ult.ready { animation: ultReadyGlow 1.5s infinite; }

@keyframes ultReadyGlow {
    0% { filter: brightness(1); box-shadow: 0 0 15px rgba(251, 191, 36, 0.5); }
    50% { filter: brightness(1.5); box-shadow: 0 0 30px rgba(251, 191, 36, 0.8); }
    100% { filter: brightness(1); box-shadow: 0 0 15px rgba(251, 191, 36, 0.5); }
}

.hud-middle {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
}

.cooldown-container { display: flex; gap: 8px; }
.cd-item {
    width: 55px;
    height: 55px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.cd-item span { font-size: 0.6rem; font-weight: 700; z-index: 2; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.cd-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(129, 131, 255, 0.4);
    transition: height 0.1s linear;
}

.currency {
    padding: 8px 15px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 20px;
    display: flex;
    gap: 10px;
}

#gold { color: var(--accent); font-weight: 700; }

.score-display {
    padding: 12px 20px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

/* Selection Screen */
.selection-container { text-align: center; max-width: 900px; padding: 2rem; }
.selection-container h1 { font-size: 3.5rem; margin-bottom: 1rem; background: linear-gradient(45deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.selection-container p { margin-bottom: 3rem; color: var(--text-secondary); }

.char-cards {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 3rem;
}

.char-card {
    width: 250px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

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

.char-card:hover::before { left: 100%; }

.char-card:hover {
    transform: translateY(-15px) scale(1.02);
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4), 0 0 20px rgba(129, 131, 255, 0.2);
}

.char-card.selected {
    border-width: 2px;
    border-color: var(--accent);
    background: rgba(251, 191, 36, 0.08);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

.card-img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.warrior-skin { background: #8183ff; }
.archer-skin { background: #34d399; }
.mage-skin { background: #a78bfa; }
.assassin-skin { background: #a855f7; }

.eye-box {
    width: 60%;
    height: 30%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: relative;
}

.eye-box::before, .eye-box::after {
    content: '';
    width: 15px;
    height: 15px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.eye-box::after, .eye-box::before {
    background: radial-gradient(circle at 65% 35%, white 0%, white 25%, black 26%, black 100%);
}

.char-card:hover .card-img { transform: scale(1.05); }
.char-card h3 { margin-bottom: 10px; color: var(--text-primary); }
.char-card p { font-size: 0.85rem; line-height: 1.4; color: var(--text-secondary); }

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.active { display: flex; animation: fadeIn 0.4s ease; }

.glow-btn {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(129, 131, 255, 0.4);
    transition: transform 0.2s;
    text-transform: uppercase;
}

.glow-btn:hover { transform: scale(1.05); }
.glow-btn.hidden { display: none; }

/* Global Glass Effect */
.glass-panel {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 35px;
    text-align: center;
}

/* Shop Panel Specifics */
.shop-panel { width: 550px; }
.shop-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 25px; }
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    text-align: left;
    border: 1px solid transparent;
    transition: all 0.3s;
}
.shop-item:hover { border-color: var(--primary); background: rgba(255,255,255,0.08); }
.shop-item span { font-weight: 700; display: block; color: var(--text-primary); }
.shop-item p { font-size: 0.8rem; color: var(--text-secondary); }

/* Shop Tabs */
.shop-tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--glass-border); padding-bottom: 15px; }
.tab-btn { padding: 8px 18px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 10px; color: white; cursor: pointer; font-weight: 700; transition: all 0.3s; }
.tab-btn.active { background: var(--primary); box-shadow: 0 0 15px rgba(129, 131, 255, 0.4); border-color: var(--primary); }
.tab-btn:hover:not(.active) { background: rgba(255,255,255,0.1); }

/* Inventory Styling */
.inventory-panel { width: 600px; max-height: 80vh; }
.inventory-layout { display: flex; flex-direction: column; gap: 25px; margin-top: 20px; }
.equipped-area { display: flex; align-items: center; gap: 20px; padding: 20px; background: rgba(255,255,255,0.03); border-radius: 15px; border: 1px solid var(--glass-border); }
.equip-slot { width: 80px; height: 80px; background: rgba(0,0,0,0.3); border: 2px solid var(--primary); border-radius: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; }
.slot-label { font-size: 0.65rem; color: var(--text-secondary); position: absolute; top: 10%; }
.item-icon { font-size: 2.2rem; }
.weapon-info h3 { color: var(--accent); margin-bottom: 5px; }
.weapon-info p { font-size: 0.9rem; margin-bottom: 10px; }

.element-tag { padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; display: inline-block; }
.element-tag.fire { background: #ef4444; color: white; box-shadow: 0 0 10px #ef4444; }
.element-tag.ice { background: #60a5fa; color: white; box-shadow: 0 0 10px #60a5fa; }
.element-tag.lightning { background: #facc15; color: black; box-shadow: 0 0 10px #facc15; }
.element-tag.void { background: #a855f7; color: white; box-shadow: 0 0 10px #a855f7; }
.element-tag.none { background: #475569; color: white; }

.inventory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; background: rgba(0,0,0,0.2); padding: 15px; border-radius: 15px; height: 280px; overflow-y: auto; }
.inv-slot { width: 100%; aspect-ratio: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 10px; display: flex; justify-content: center; align-items: center; cursor: pointer; font-size: 1.8rem; transition: all 0.2s; }
.inv-slot:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }
.inv-slot.empty { opacity: 0.3; cursor: default; }

.inv-actions { display: flex; gap: 15px; margin-top: 20px; }
.glow-btn.small { padding: 8px 18px; font-size: 0.9rem; }

/* Skill Panel */
.skill-panel { width: 450px; }
.skill-list { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.skill-upgrade-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: rgba(255,255,255,0.05); border-radius: 10px; }
.skill-name { font-weight: 700; }
.skill-level { font-size: 0.8rem; color: var(--accent); }
.upgrade-btn { padding: 4px 10px; background: var(--xp-color); border: none; border-radius: 5px; color: black; font-weight: 700; cursor: pointer; }
.upgrade-btn:disabled { background: #475569; cursor: not-allowed; }

/* Boss HUD */
#boss-hud {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    z-index: 100;
    pointer-events: none;
    transition: opacity 1s ease;
}

.boss-info {
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    padding: 15px 25px;
    border-radius: 20px;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

#boss-name {
    display: block;
    font-size: 1.4rem;
    font-weight: 800;
    color: #ff4d4d;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 77, 77, 0.6);
}

.boss-hp-container {
    width: 100%;
    height: 18px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

.boss-hp-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff0000, #990000);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    transition: width 0.4s cubic-bezier(0.1, 0.7, 1.0, 0.1);
}

#boss-hud.hidden { opacity: 0; pointer-events: none; }

/* Boss Warning Effect */
@keyframes redFlash { 
    0% { box-shadow: inset 0 0 0px rgba(255, 0, 0, 0); } 
    50% { box-shadow: inset 0 0 150px rgba(255, 0, 0, 0.4); } 
    100% { box-shadow: inset 0 0 0px rgba(255, 0, 0, 0); } 
}
.boss-warning-active { animation: redFlash 2.5s infinite; }

#action-hint { 
position: absolute; bottom: 30px; font-size: 0.85rem; color: var(--text-secondary); opacity: 0.8; z-index: 60; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes successPulse { 0% { box-shadow: 0 0 0px var(--accent); } 50% { box-shadow: 0 0 30px var(--accent); } 100% { box-shadow: 0 0 0px var(--accent); } }
.success-anim { animation: successPulse 0.5s ease; }
