:root {
    --bg-color: #000;
    --panel-bg: rgba(20, 25, 35, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #a855f7;
    --glass-border: 1px solid rgba(255, 255, 255, 0.15);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden; 
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; 
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-header {
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.game-header h1 {
    font-size: 2.5rem;
    margin-bottom: 4px;
    letter-spacing: 2px;
    font-weight: 800;
}

.game-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 320px;
    line-height: 1.5;
    margin-top: -5px;
}

#leaderboard-container {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 15px;
    width: 300px;
    margin-top: 15px;
    margin-bottom: auto;
    pointer-events: auto;
}

#leaderboard-container h3 {
    margin-bottom: 10px;
    color: var(--accent-blue);
}

.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.2s;
}

.tab-btn.active {
    background: var(--accent-blue);
    font-weight: 600;
}

#leaderboard-list, #leaderboard-sticky-bottom {
    list-style: none;
    font-size: 0.95rem;
    padding: 0;
    margin: 0;
}

#leaderboard-list li, #leaderboard-sticky-bottom li {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    margin-bottom: 5px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
}

#leaderboard-scroll-area::-webkit-scrollbar {
    width: 6px;
}
#leaderboard-scroll-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
#leaderboard-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
#leaderboard-scroll-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.stats-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: var(--border-radius);
    padding: 20px;
    width: 300px;
    pointer-events: auto;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
}

.stat-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    margin-bottom: 16px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease-out;
    width: 100%;
}

.hp-fill { background: var(--accent-green); }
.xp-fill { background: var(--accent-blue); width: 0%; }

.cooldown-panel {
    margin-top: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 15px;
}
.cooldown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.cd-bar-bg {
    width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}
.cd-bar-fill {
    height: 100%;
    background: var(--accent-purple);
    width: 100%;
}

#combat-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 800;
    color: #fbbf24;
    text-shadow: 0 4px 15px rgba(0,0,0,1);
    transition: opacity 0.3s, transform 0.3s;
}

#combat-message.hidden {
    opacity: 0;
    transform: translate(-50%, -40%);
}

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

.floating-text {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,1);
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.2); }
}

#start-screen, #game-over-panel {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    pointer-events: auto;
}

#start-screen > div, #game-over-panel > div {
    text-align: center;
    border: var(--glass-border);
    padding: 40px;
    border-radius: 16px;
    background: var(--panel-bg);
}

#start-screen h1, #game-over-panel h2 {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--accent-purple);
}

#game-over-panel h2 { color: #ef4444; }

#start-screen p, #game-over-panel p {
    margin-bottom: 30px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.ui-btn {
    background: var(--text-primary);
    color: var(--bg-color);
    border: none;
    padding: 14px 32px;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    pointer-events: auto;
}

.ui-btn:hover { transform: scale(1.05); }
.ui-btn:disabled { background: #64748b; cursor: not-allowed; transform: none; }

/* Shop UI */
#shop-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    border: 2px solid var(--accent-purple);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    width: 750px;
    max-width: 95%;
    pointer-events: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    z-index: 15;
}

#shop-panel h2 {
    font-size: 2.8rem;
    color: var(--accent-purple);
    margin-bottom: 5px;
}

.shop-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.shop-items {
    display: flex;
    justify-content: space-between;
    gap: 24px;
}

.shop-item {
    background: rgba(255,255,255,0.05);
    border: var(--glass-border);
    padding: 24px 20px;
    border-radius: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, background 0.2s;
}

.shop-item:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-5px);
}

.shop-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.shop-item h3 { margin-bottom: 10px; font-size: 1.3rem; }
.shop-item p { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 24px; flex-grow: 1; line-height: 1.4; }

.shop-item .ui-btn {
    width: 100%;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 1.05rem;
}

.hidden { display: none !important; }
