:root {
    --primary-color: #00ff00;
    --secondary-color: #008800;
    --bg-color: #111;
    --ui-bg: rgba(0, 0, 0, 0.8);
    --text-color: #eee;
    --font-title: 'Orbitron', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to canvas when playing */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#ui-layer>* {
    pointer-events: auto;
    /* Re-enable clicks for UI elements */
}

/* Lobby Styles */
#lobby-screen {
    background: var(--ui-bg);
    padding: 2rem;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.2);
}

.title {
    font-family: var(--font-title);
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #fff;
    text-shadow: 0 0 10px var(--primary-color);
}

.highlight {
    color: var(--primary-color);
}

.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--secondary-color);
    padding: 10px;
    color: #fff;
    font-family: var(--font-body);
    font-size: 1.2rem;
    border-radius: 5px;
    text-align: center;
    width: 250px;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    font-family: var(--font-title);
    font-size: 1.2rem;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn.primary {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 10px var(--secondary-color);
}

.btn.primary:hover {
    background: #fff;
    box-shadow: 0 0 20px #fff;
}

.btn.secondary {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn.secondary:hover {
    background: rgba(0, 255, 0, 0.1);
}

.join-group {
    display: flex;
    gap: 10px;
}

#room-code-input {
    width: 120px;
}

/* HUD Styles */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.room-info {
    font-family: var(--font-title);
    color: rgba(255, 255, 255, 0.7);
    pointer-events: auto;
    cursor: pointer;
}

.health-bar-container {
    width: 300px;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
}

.health-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff3333, #ffff33, #33ff33);
    width: 100%;
    transition: width 0.2s;
}

#health-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

.weapon-selector {
    align-self: center;
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 20px;
}

.weapon {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-title);
    font-size: 0.9rem;
}

.weapon.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.2);
}

.key {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 5px;
}

#cooldown-display {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-title);
    color: #ff3333;
    font-weight: bold;
    text-shadow: 0 0 5px #ff0000;
    opacity: 0;
    transition: opacity 0.2s;
}

#game-over-screen {
    background: rgba(0, 0, 0, 0.9);
    padding: 3rem;
    border: 2px solid #fff;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
}

#game-over-screen h2 {
    font-family: var(--font-title);
    font-size: 4rem;
    color: #ff3333;
    margin-bottom: 1rem;
}

#winner-text {
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

/* Help Legend */
#help-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

.legend-section {
    margin-bottom: 10px;
}

.legend-section:last-child {
    margin-bottom: 0;
}

.legend-section h3 {
    font-family: var(--font-title);
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 2px;
}

.legend-item {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.key-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #fff;
}

.icon-health {
    color: #ff3333;
    font-weight: bold;
}

.icon-armor {
    color: #3388ff;
    font-weight: bold;
}

.icon-damage {
    color: #ffaa00;
    font-weight: bold;
}

/* Room Code Copy Animation */
@keyframes copyFlash {
    0% {
        color: #fff;
        transform: scale(1);
    }

    50% {
        color: var(--primary-color);
        transform: scale(1.2);
        text-shadow: 0 0 15px var(--primary-color);
    }

    100% {
        color: rgba(255, 255, 255, 0.7);
        transform: scale(1);
    }
}

.copied-anim {
    animation: copyFlash 0.5s ease-out;
}

/* Tooltip for copied */
#room-code-display {
    position: relative;
}

#room-code-display::after {
    content: "COPIED!";
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

#room-code-display.copied-anim::after {
    opacity: 1;
}