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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a1628;
    color: #fff;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0a1628 0%, #1a3a5c 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(100, 200, 255, 0.3);
    border-top-color: #64c8ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading-screen p {
    margin-top: 20px;
    font-size: 18px;
    color: #64c8ff;
}

/* Login options */
#login-options {
    margin-top: 30px;
    text-align: center;
}

#login-options.hidden {
    display: none;
}

.login-title {
    font-size: 16px;
    color: #aaa;
    margin-bottom: 20px;
}

#telegram-login-container {
    margin-bottom: 15px;
}

.offline-btn {
    padding: 12px 24px;
    background: transparent;
    border: 1px solid rgba(100, 200, 255, 0.5);
    color: #64c8ff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.offline-btn:hover {
    background: rgba(100, 200, 255, 0.1);
    border-color: #64c8ff;
}

.login-hint {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
}

/* Game Container */
#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

#hud > div {
    background: rgba(0, 20, 40, 0.8);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(100, 200, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

#hud .icon {
    font-size: 16px;
}

/* Username display */
#user-display {
    background: rgba(0, 40, 60, 0.9) !important;
    border-color: rgba(100, 200, 255, 0.5) !important;
}

#username-value {
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#username-value.online {
    color: #4ade80;
}

#username-value.offline {
    color: #888;
}

#wear-display {
    flex-direction: column;
    align-items: flex-start !important;
}

#wear-bar {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

#wear-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #fbbf24, #ef4444);
    transition: width 0.3s;
}

/* Harpoon Cooldown */
#harpoon-display {
    flex-direction: row !important;
    gap: 8px;
}

#harpoon-bar {
    width: 60px;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

#harpoon-fill {
    height: 100%;
    width: 100%;
    background: #4ade80;
    transition: width 0.1s linear;
}

#harpoon-fill.reloading {
    background: linear-gradient(90deg, #ef4444, #fbbf24);
}

#harpoon-status {
    font-size: 12px;
    min-width: 50px;
}

#harpoon-status.ready {
    color: #4ade80;
}

#harpoon-status.reloading {
    color: #fbbf24;
}

/* Radar */
#radar {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 150px;
    height: 150px;
    background: rgba(0, 20, 40, 0.8);
    border-radius: 50%;
    border: 2px solid rgba(100, 200, 255, 0.5);
    overflow: hidden;
    z-index: 10;
    opacity: 0.85;
}

#radar-canvas {
    width: 100%;
    height: 100%;
}

#radar-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px #4ade80;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 10;
}

#joystick-container {
    width: 120px;
    height: 120px;
}

#joystick-base {
    width: 100%;
    height: 100%;
    background: rgba(0, 20, 40, 0.6);
    border: 2px solid rgba(100, 200, 255, 0.4);
    border-radius: 50%;
    position: relative;
}

#joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(100, 200, 255, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.1s;
}

#vertical-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
}

.vertical-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(100, 200, 255, 0.5);
    background: rgba(0, 20, 40, 0.8);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.vertical-btn:active {
    transform: scale(0.95);
    background: rgba(100, 200, 255, 0.3);
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(100, 200, 255, 0.5);
    background: rgba(0, 20, 40, 0.8);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:active {
    transform: scale(0.95);
    background: rgba(100, 200, 255, 0.3);
}

.action-btn.hidden {
    display: none;
}

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
}

.crosshair-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.7);
}

.crosshair-line.horizontal {
    width: 20px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair-line.vertical {
    width: 2px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ff4444;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* QTE Panel */
#qte-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #64c8ff;
    border-radius: 16px;
    padding: 20px 30px;
    text-align: center;
    z-index: 100;
    min-width: 300px;
}

#qte-panel.hidden {
    display: none;
}

#qte-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: #64c8ff;
}

#qte-prompts {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.qte-prompt {
    width: 50px;
    height: 50px;
    border: 2px solid #64c8ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(100, 200, 255, 0.1);
    transition: all 0.2s;
}

.qte-prompt.active {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
    transform: scale(1.1);
}

.qte-prompt.success {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.3);
}

.qte-prompt.failed {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.3);
}

#qte-timer {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

#qte-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4ade80, #fbbf24);
    transition: width 0.1s linear;
}

#qte-result {
    font-size: 16px;
    min-height: 24px;
}

/* Station Panel */
#station-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #64c8ff;
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    min-width: 350px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

#station-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(100, 200, 255, 0.3);
}

.panel-header h2 {
    font-size: 20px;
    color: #64c8ff;
}

.close-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(239, 68, 68, 0.3);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}

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

.tab-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid rgba(100, 200, 255, 0.3);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: rgba(100, 200, 255, 0.2);
    border-color: #64c8ff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.repair-info {
    margin-bottom: 15px;
}

.repair-info p {
    margin-bottom: 8px;
    color: #ccc;
}

.primary-btn {
    width: 100%;
    padding: 12px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#cargo-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.cargo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.cargo-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cargo-item-rarity {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.rarity-common { background: #9ca3af; }
.rarity-uncommon { background: #4ade80; }
.rarity-rare { background: #3b82f6; }
.rarity-legendary { background: #a855f7; }
.rarity-unique { background: #f97316; }

.cargo-item-price {
    color: #fbbf24;
}

.cargo-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sell-item-btn {
    padding: 5px 10px;
    background: rgba(239, 68, 68, 0.3);
    border: 1px solid #ef4444;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.sell-item-btn:hover {
    background: rgba(239, 68, 68, 0.5);
}

/* Notifications */
#notifications {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 50;
}

.notification {
    background: rgba(0, 20, 40, 0.9);
    border: 1px solid rgba(100, 200, 255, 0.5);
    padding: 10px 20px;
    border-radius: 8px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    white-space: nowrap;
}

.notification.success {
    border-color: #4ade80;
    color: #4ade80;
}

.notification.error {
    border-color: #ef4444;
    color: #ef4444;
}

.notification.warning {
    border-color: #fbbf24;
    color: #fbbf24;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* Dock Button */
.dock-btn {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2px solid #64c8ff;
    color: #fff;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    z-index: 20;
    animation: pulse 2s infinite;
}

.dock-btn.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(100, 200, 255, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(100, 200, 255, 0); }
}

/* Mobile adjustments */
@media (max-width: 767px) {
    #hud {
        top: 50px;
        left: 5px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        max-width: 50%;
    }
    
    #hud > div {
        padding: 4px 8px;
        font-size: 11px;
        gap: 4px;
    }
    
    #hud .icon {
        font-size: 12px;
    }
    
    /* Hide username on mobile to save space */
    #user-display {
        display: none !important;
    }
    
    #resources-display {
        display: none;
    }
    
    #radar {
        width: 70px;
        height: 70px;
        border-width: 1px;
    }
    
    #crosshair {
        display: none;
    }
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #mobile-controls {
        display: none;
    }
    
    #radar {
        width: 200px;
        height: 200px;
    }
}

/* Utility */
.hidden {
    display: none !important;
}


/* Clickable cargo display */
#cargo-display.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

#cargo-display.clickable:hover {
    background: rgba(100, 200, 255, 0.2);
    border-color: #64c8ff;
}

/* Inventory Panel */
#inventory-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #64c8ff;
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    min-width: 320px;
    max-width: 90vw;
    max-height: 70vh;
    overflow-y: auto;
}

#inventory-panel.hidden {
    display: none;
}

#inventory-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
}

#inventory-list .cargo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

#inventory-total {
    text-align: right;
    padding: 10px;
    border-top: 1px solid rgba(100, 200, 255, 0.3);
    color: #fbbf24;
    font-weight: bold;
}

.inventory-empty {
    text-align: center;
    color: #666;
    padding: 30px;
}


/* Pump Panel */
#pump-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 20, 40, 0.95);
    border: 2px solid #00ffff;
    border-radius: 16px;
    padding: 20px;
    z-index: 100;
    min-width: 320px;
    max-width: 90vw;
}

#pump-panel.hidden {
    display: none;
}

.pump-info {
    margin-bottom: 15px;
}

.pump-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(100, 200, 255, 0.1);
}

.pump-stat:last-of-type {
    border-bottom: none;
}

.pump-storage-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

#pump-storage-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00ffff, #00ff88);
    transition: width 0.3s;
}

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

.pump-actions .primary-btn {
    background: linear-gradient(135deg, #00aaff, #0066cc);
}

.secondary-btn {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(100, 200, 255, 0.5);
    background: rgba(100, 200, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(100, 200, 255, 0.2);
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.danger-btn {
    width: 100%;
    padding: 10px;
    border: 1px solid #ef4444;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.4);
}

.status-active {
    color: #4ade80;
}

.status-inactive {
    color: #ef4444;
}

/* Resource Info Tooltip */
#resource-info {
    position: absolute;
    bottom: 180px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 40, 0.9);
    border: 1px solid rgba(100, 200, 255, 0.5);
    border-radius: 8px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
}

#resource-info.hidden {
    display: none;
}

#resource-icon {
    font-size: 24px;
}

#resource-name {
    font-weight: bold;
    color: #64c8ff;
}

#resource-amount {
    color: #aaa;
}

/* Deploy Pump Button */
.deploy-btn {
    position: absolute;
    bottom: 230px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: linear-gradient(135deg, #00aaff, #0066cc);
    border: 2px solid #00ffff;
    color: #fff;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    z-index: 20;
    animation: pulse 2s infinite;
}

.deploy-btn.hidden {
    display: none;
}

/* Resources Button */
.resources-btn {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(100, 200, 255, 0.5);
    background: rgba(0, 20, 40, 0.8);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 15;
    transition: all 0.2s;
}

.resources-btn:active {
    transform: translateX(-50%) scale(0.95);
    background: rgba(100, 200, 255, 0.3);
}

/* Resources Panel */
#resources-panel {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 20, 40, 0.95);
    border: 1px solid rgba(100, 200, 255, 0.5);
    border-radius: 12px;
    padding: 10px;
    z-index: 20;
    min-width: 150px;
}

#resources-panel.hidden {
    display: none;
}

.resources-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(100, 200, 255, 0.3);
    font-weight: bold;
    color: #64c8ff;
}

.close-btn-small {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
}

.resource-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.resource-row span:last-child {
    color: #4ade80;
    font-weight: bold;
}

/* Resources sell tab */
.resources-prices {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.prices-title {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.price-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
    color: #ccc;
}

.price-row span {
    color: #fbbf24;
}

#resources-list {
    margin-bottom: 15px;
}

.resource-sell-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.resource-sell-row span:first-child {
    flex: 1;
}

.resource-sell-row span:nth-child(2) {
    min-width: 50px;
    text-align: right;
    margin-right: 10px;
    color: #64c8ff;
    font-weight: bold;
}

.sell-resource-btn {
    padding: 6px 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.sell-resource-btn:hover {
    transform: scale(1.05);
}

.sell-resource-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
