:root {
    --primary: #646cff;
    --bg: #1a1a1a;
    --glass: rgba(255, 255, 255, 0.1);
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg);
    font-family: 'Inter', sans-serif;
    color: white;
}

canvas {
    display: block;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10;
    transition: opacity 0.5s ease;
}

#ui-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.glass-panel {
    background: var(--glass);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
    margin: 0 0 1rem 0;
    font-size: 2.5rem;
    background: linear-gradient(45deg, #ff00cc, #3333ff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.8rem;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    margin-bottom: 1rem;
    width: 200px;
    outline: none;
    transition: border-color 0.3s;
}

input:focus {
    border-color: var(--primary);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

button:hover {
    background: #535bf2;
    transform: translateY(-2px);
}

#player-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.label {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    transform: translate(-50%, -100%);
    white-space: nowrap;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#player-count {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
}

#chat-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 300px;
    pointer-events: auto;
}

#chat-messages {
    height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-bottom: 10px;
    mask-image: linear-gradient(to top, black 80%, transparent 100%);
}

.chat-msg {
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 14px;
    animation: fadein 0.2s;
}

.chat-msg b {
    color: #aaa;
}

#chat-input {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
}

#cooldown-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    text-align: right;
}

.cooldown-bar-bg {
    width: 150px;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

.cooldown-bar-fill {
    width: 100%;
    height: 100%;
    background: #00ff88;
    transform-origin: left;
    transform: scaleX(1);
    transition: transform 0.1s linear;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#leaderboard {
    position: absolute;
    top: 70px;
    right: 20px;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 15px;
    border-radius: 10px;
    min-width: 150px;
}

.leaderboard-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #ffd700;
    font-size: 14px;
}

#leaderboard-list {
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item.self {
    color: #00ff88;
    font-weight: bold;
}

.leaderboard-rank {
    margin-right: 8px;
    color: #888;
}

.leaderboard-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    margin-left: 10px;
    color: #ffd700;
}