body {
    margin: 0;
    overflow: hidden;
    background-color: #050510;
    font-family: 'Orbitron', sans-serif;
    color: #0ff;
    text-transform: uppercase;
}

canvas {
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* HUD Panels (Glassmorphism) */
.hud-panel {
    background: rgba(0, 15, 30, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
    border-radius: 4px;
    pointer-events: auto;
}

/* Top Left Status */
#hud-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 15px;
    min-width: 200px;
}

#coords {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 5px;
}

#hud-credits {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* Leaderboard */
#leaderboard {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    padding: 15px;
}

#leaderboard h3 {
    margin: 0 0 10px 0;
    text-align: center;
    color: #0ff;
    font-size: 16px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    padding-bottom: 5px;
}

#leaderboard ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

/* Chat */
#chat-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 350px;
    padding: 15px;
}

#chat-messages {
    height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
    font-size: 12px;
    color: #ddd;
}

.chat-msg {
    margin-bottom: 4px;
    word-wrap: break-word;
}

.chat-msg .id {
    font-weight: bold;
    color: #0ff;
}

#chat-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: white;
    padding: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    box-sizing: border-box;
}

#chat-input:focus {
    outline: none;
    border-color: #0ff;
    box-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

/* Shop Prompt */
#shop-prompt {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 15px 30px;
    border: 1px solid #ffd700;
    border-radius: 20px;
    font-size: 18px;
    color: #ffd700;
    text-align: center;
    pointer-events: none;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* Shop UI */
#shop-ui {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 650px;
    background: rgba(5, 10, 20, 0.95);
    border: 1px solid #0ff;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 100;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    background: rgba(0, 255, 255, 0.05);
}

.shop-header h2 {
    margin: 0;
    color: #0ff;
    font-size: 24px;
    letter-spacing: 2px;
}

#close-shop {
    background: none;
    border: 1px solid rgba(255, 0, 0, 0.5);
    color: #ff5555;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 15px;
    transition: all 0.2s;
}

#close-shop:hover {
    background: rgba(255, 0, 0, 0.2);
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}

.shop-content {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
}

.shop-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    padding: 15px;
    overflow-y: auto;
}

.shop-section h3 {
    margin-top: 0;
    color: #888;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    font-size: 14px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    padding: 10px;
}

.shop-item {
    background: rgba(0, 20, 40, 0.5);
    border: 1px solid #333;
    border-radius: 4px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.shop-item:hover {
    border-color: #0ff;
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.shop-item img {
    width: 40px;
    height: 40px;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.shop-item .name {
    font-size: 10px;
    font-weight: bold;
    display: block;
    color: #fff;
    margin-bottom: 5px;
}

.shop-item .price {
    font-size: 10px;
    color: #ffd700;
    display: block;
}

.shop-footer {
    padding: 20px;
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    text-align: right;
    font-size: 20px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
}

/* Mission HUD */
#mission-hud {
    position: absolute;
    top: 220px;
    /* Below status */
    left: 20px;
    width: 200px;
    border-color: #ffd700;
}

#mission-hud h3 {
    margin: 0 0 10px 0;
    color: #ffd700;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 5px;
}

#mission-text {
    font-size: 12px;
    margin-bottom: 10px;
    text-align: center;
    color: #fff;
}

#mission-progress {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    color: #0ff;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Stat Bars */
.stat-container {
    margin-top: 10px;
}

.stat-label {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
}

.stat-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.2s;
    box-shadow: 0 0 5px currentColor;
}

/* Group List Items */
.group-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    padding: 10px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-item:hover {
    background: rgba(255, 204, 0, 0.1);
    border-color: #ffcc00;
}

.group-item .name {
    color: #fff;
    font-weight: bold;
}

.group-item .count {
    color: #aaa;
    font-size: 12px;
}

.group-item button {
    background: #ffcc00;
    color: black;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Orbitron', sans-serif;
}

.group-item button:hover {
    background: #ffe066;
}

/* Station UI */
#station-ui {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    height: 600px;
    background-color: rgba(0, 20, 40, 0.95);
    border: 2px solid #00ff00;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    color: white;
    font-family: 'Orbitron', sans-serif;
    z-index: 2000;
}

.station-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #00ff00;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.station-content {
    display: flex;
    flex: 1;
    gap: 20px;
    overflow: hidden;
}

.station-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border: 1px solid #004400;
}

.station-footer {
    margin-top: 20px;
    border-top: 1px solid #00ff00;
    padding-top: 10px;
}

.item-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.station-item {
    display: flex;
    justify-content: space-between;
    padding: 5px;
    background: rgba(0, 255, 0, 0.1);
    cursor: pointer;
}

.station-item:hover {
    background: rgba(0, 255, 0, 0.3);
}

#btn-station-close {
    background: red;
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-family: 'Orbitron';
}

#btn-station-collect {
    background: #00ff00;
    color: black;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-family: 'Orbitron';
    margin-left: 10px;
}

/* Trade UI */
#trade-modal input[type=number] {
    padding: 5px;
    font-family: 'Orbitron', sans-serif;
    color: white;
}

#nearby-players-panel .player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid #333;
    font-size: 12px;
}

#nearby-players-panel .player-item:hover {
    background: rgba(0, 255, 255, 0.1);
}

#nearby-players-panel button {
    background: #00ffcc;
    color: black;
    border: none;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
}

#trade-modal,
#nearby-players-panel,
#trade-request-modal {
    pointer-events: auto;
}

/* Joystick Styles */
#joystick-base {
    position: absolute;
    bottom: 50px;
    left: 50px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 50%;
    touch-action: none;
    display: none;
    /* Hidden by default, shown via JS on mobile */
    z-index: 5000;
}

#joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(0, 255, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    /* Center initially, overridden by JS translate */
    margin-top: -25px;
    /* Half height */
    margin-left: -25px;
    /* Half width */
    box-shadow: 0 0 10px cyan;
    pointer-events: none;
}

@media (max-width: 768px) {
    #joystick-base {
        display: block;
    }
}

#joystick-base.visible {
    display: block !important;
}