body {
    margin: 0;
    overflow: hidden;
    background-color: #050508;
    font-family: 'Segoe UI', sans-serif;
    user-select: none;
}

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

#svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}

.connector-path {
    fill: none;
    stroke: #58a6ff;
    stroke-width: 1.5;
    opacity: 0.5;
    filter: drop-shadow(0 0 2px rgba(88, 166, 255, 0.5));
    vector-effect: non-scaling-stroke;
}

.connector-path.danger {
    stroke: #e74c3c;
    filter: drop-shadow(0 0 2px rgba(231, 76, 60, 0.5));
}

.connector-dot {
    fill: #58a6ff;
}

#ui-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    width: 280px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #30363d;
    border-radius: 4px;
    padding: 12px;
    color: #c9d1d9;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    font-size: 12px;
    pointer-events: auto;
    max-height: 90vh;
    overflow-y: auto;
}

/* Mobile Toggle Button */
.mobile-toggle {
    display: none;
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
        position: absolute;
        top: 70px;
        left: 10px;
        z-index: 500;
        padding: 8px 12px;
        background: rgba(13, 17, 23, 0.95);
        border: 1px solid #30363d;
        color: #58a6ff;
        border-radius: 4px;
        cursor: pointer;
        font-weight: bold;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    }

    #ui-layer {
        position: fixed;
        width: 280px !important;
        left: 0 !important;
        top: 0 !important;
        height: 100vh;
        max-height: 100vh !important;
        margin: 0;
        border-radius: 0;
        border-left: none;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
        z-index: 400;
        transition: transform 0.3s ease;
        padding-top: 80px;
        /* Space for top elements */
        overflow-y: auto;
    }

    #ui-layer.collapsed {
        transform: translateX(-100%);
    }

    /* Ensure inputs are touch-friendly */
    input[type="text"],
    input[type="number"],
    select,
    button {
        min-height: 40px;
        /* Larger touch targets */
        font-size: 14px;
    }

    button.small-btn {
        min-height: 30px;
    }

    .list-item {
        padding: 8px 5px;
    }
}

#ui-layer::-webkit-scrollbar {
    width: 4px;
}

#ui-layer::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

h3 {
    margin: 0 0 10px 0;
    color: #58a6ff;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.5px;
}

input[type="text"] {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 5px;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 12px;
}

input[type="text"]:focus {
    outline: none;
    border-color: #58a6ff;
}

button {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    width: 100%;
    transition: all 0.2s;
}

button:hover {
    background: #30363d;
    border-color: #8b949e;
}

button.active {
    background: #1f6feb;
    color: white;
    border-color: #1f6feb;
}

button.action-btn {
    margin-top: 5px;
    font-weight: bold;
}

button.small-btn {
    width: auto;
    padding: 2px 6px;
    font-weight: bold;
}

.btn-danger {
    background: #5a1e1e;
    border-color: #8c2a2a;
    color: #ffcccc;
}

.btn-danger:hover {
    background: #752525;
    border-color: #b33636;
}

select {
    width: 100%;
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 4px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.divider {
    height: 1px;
    background: #30363d;
    margin: 10px 0;
}

#results {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 5px;
    list-style: none;
    padding: 0;
    border: 1px solid #30363d;
    border-radius: 4px;
    display: none;
    background: #0d1117;
    position: relative;
    z-index: 200;
    pointer-events: auto;
}

#results.show {
    display: block;
}

.res-item {
    padding: 5px 8px;
    border-bottom: 1px solid #21262d;
    cursor: pointer;
    transition: background 0.2s;
}

.res-item:hover {
    background: #161b22;
    color: #58a6ff;
}

.ctrl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.ctrl-label {
    display: flex;
    align-items: center;
    width: 100px;
    color: #8b949e;
}

.ctrl-label input[type="checkbox"] {
    margin-right: 6px;
    cursor: pointer;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 90px;
    height: 3px;
    background: #30363d;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: 2px solid #0d1117;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.dot-local {
    background: #666;
}

.dot-const {
    background: #d63031;
}

.dot-region {
    background: #00a8ff;
}

.data-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 2px;
    color: #8b949e;
}

.timer-val {
    font-family: monospace;
    color: #eee;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    background: #444;
}

.status-dot.active {
    background: #2ecc71;
    box-shadow: 0 0 5px #2ecc71;
}

#route-details {
    display: none;
    margin-top: 10px;
    border-top: 1px solid #30363d;
    padding-top: 10px;
}

#route-details.show {
    display: block;
}

.route-header {
    cursor: pointer;
    font-weight: 600;
    color: #58a6ff;
    display: flex;
    justify-content: space-between;
}

.route-header:hover {
    color: #fff;
}

.route-point {
    margin-bottom: 6px;
}

.route-label {
    font-size: 10px;
    color: #8b949e;
    display: block;
    margin-bottom: 2px;
}

.selected-sys {
    font-size: 12px;
    color: #eee;
    font-family: monospace;
    border: 1px solid #30363d;
    padding: 3px;
    border-radius: 3px;
    background: #161b22;
    min-height: 20px;
    display: flex;
    align-items: center;
}

.selected-sys.placeholder {
    color: #555;
    font-style: italic;
}

.route-ctrl-row {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.list-container {
    max-height: 80px;
    overflow-y: auto;
    border: 1px solid #30363d;
    border-radius: 3px;
    background: #0d1117;
    margin-top: 5px;
}

.list-item {
    font-size: 11px;
    padding: 3px 5px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #222;
    align-items: center;
}

.list-rm {
    color: #e74c3c;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    line-height: 10px;
    padding: 2px;
}

.list-rm:hover {
    color: #ff6b6b;
}

.jb-inputs {
    display: flex;
    gap: 4px;
    margin-top: 5px;
}

.jb-inputs input {
    width: 40%;
    font-size: 10px;
    padding: 3px;
}

.route-marker {
    color: #fff;
    font-weight: bold;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    box-shadow: 0 0 5px #000;
}

.marker-fancy {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.marker-fancy::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid;
    border-radius: 50%;
    box-sizing: border-box;
    animation: marker-pulse 1.5s infinite;
}

.marker-fancy::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.marker-origin {
    color: #2ecc71;
}

.marker-dest {
    color: #e74c3c;
}

.marker-label {
    position: absolute;
    top: -18px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 0 0 4px #000;
    white-space: nowrap;
    color: inherit;
}

@keyframes marker-pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
        border-width: 2px;
    }

    100% {
        transform: scale(2.0);
        opacity: 0;
        border-width: 0px;
    }
}

#intel-popup {
    position: absolute;
    display: none;
    z-index: 100;
    width: 300px;
    top: 100px;
    left: 300px;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #30363d;
    border-top: 3px solid #58a6ff;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    color: #c9d1d9;
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    transition: opacity 0.2s;
}

#intel-popup.danger {
    border-top-color: #e74c3c;
}

@media (max-width: 768px) {
    #intel-popup {
        width: 90%;
        left: 5%;
        top: 20%;
        z-index: 1001;
        /* Ensure above other UIs */
    }
}

.intel-header {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.intel-title {
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
}

.intel-close {
    cursor: pointer;
    color: #666;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s;
}

.intel-close:hover {
    color: #fff;
}

.intel-body {
    padding: 4px 0;
    max-height: 300px;
    overflow-y: auto;
}

.kill-row {
    display: grid;
    grid-template-columns: 3fr 1fr 2fr;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.kill-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.kill-row.current-system {
    background: rgba(88, 166, 255, 0.1);
    border-bottom: 1px solid rgba(88, 166, 255, 0.2);
    margin-bottom: 5px;
}

.kill-row.high-danger .sys-name {
    color: #ff6b6b;
}

.kill-row.high-danger {
    background: rgba(231, 76, 60, 0.05);
}

.sys-name-group {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sys-name {
    font-weight: 600;
    color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sys-sec {
    font-size: 10px;
    margin-top: 1px;
    opacity: 0.7;
}

.stats-group {
    display: flex;
    gap: 8px;
    font-family: 'Consolas', monospace;
    justify-content: flex-end;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
    color: #8b949e;
}

.jump-stat {
    color: #58a6ff;
    font-weight: bold;
    text-align: center;
    font-family: 'Consolas', monospace;
    opacity: 0.9;
}

.icon-ship {
    color: #ff6b6b;
}

.icon-pod {
    color: #f1c40f;
}

.icon-npc {
    color: #2ecc71;
}

.icon-jump {
    font-size: 10px;
}

.intel-body::-webkit-scrollbar {
    width: 4px;
}

.intel-body::-webkit-scrollbar-track {
    background: transparent;
}

.intel-body::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

#tooltip {
    position: absolute;
    display: none;
    pointer-events: none;
    background: rgba(13, 17, 23, 0.95);
    border: 1px solid #30363d;
    padding: 6px 10px;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 11px;
    z-index: 200;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.sec-high {
    color: #2ecc71;
}

.sec-low {
    color: #f1c40f;
}

.sec-null {
    color: #e74c3c;
}

.region-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 2px 4px #000;
    pointer-events: none;
    transition: opacity 0.3s;
    display: block;
}

.tac-card {
    font-family: 'Segoe UI', sans-serif;
    font-size: 10px;
    color: #eee;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid #444;
    border-left: 2px solid #58a6ff;
    border-radius: 2px;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 90px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    transition: opacity 0.3s, transform 0.3s, margin-top 0.2s cubic-bezier(0.25, 0.8, 0.5, 1);
    opacity: 0;
    transform: scale(0.9);
    position: relative;
}

.tac-card::before {
    content: '';
    position: absolute;
    left: -2px;
    top: -10px;
    width: 2px;
    height: 10px;
    background: #58a6ff;
    display: none;
    opacity: 0.7;
}

.tac-card.pushed::before {
    display: block;
    height: var(--push-amount, 10px);
    top: calc(var(--push-amount, 10px) * -1);
}

.tac-card.visible {
    opacity: 1;
    transform: scale(1);
}

.tac-card.danger {
    border-left-color: #ff4757;
    background: rgba(40, 10, 10, 0.85);
}

.tac-card.danger::before {
    background: #ff4757;
}

.tac-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 2px;
}

.tac-sec {
    font-family: monospace;
    font-size: 9px;
}

.tac-row {
    display: flex;
    justify-content: space-between;
    color: #aaa;
    font-family: monospace;
}

.tac-val {
    color: #fff;
    font-weight: bold;
}

.tac-hl {
    color: #58a6ff;
}

.tac-hl-danger {
    color: #ff4757;
}

/* 战略模式样式 */
#btn-strat-mode {
    background: #4a1e5a;
    border-color: #7c3aed;
    color: #e9d5ff;
    margin-top: 5px;
}

#btn-strat-mode:hover {
    background: #5b21b6;
    border-color: #8b5cf6;
}

#btn-strat-mode.active {
    background: #7c3aed;
    color: #fff;
    box-shadow: 0 0 10px #7c3aed;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0% {
        border-color: #7c3aed;
    }

    50% {
        border-color: #fff;
    }

    100% {
        border-color: #7c3aed;
    }
}

#kill-feed-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 320px;
    height: 300px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid #444;
    border-top: 3px solid #7c3aed;
    color: #ccc;
    z-index: 100;
    display: none;
    flex-direction: column;
    font-family: 'Consolas', monospace;
    font-size: 11px;
    backdrop-filter: blur(5px);
    box-shadow: -5px 5px 20px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    #kill-feed-panel {
        position: fixed;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 60vh;
        /* Taller when open */
        max-height: 60vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        transition: transform 0.3s ease;
        z-index: 450;
    }

    #kill-feed-panel.collapsed {
        transform: translateY(100%);
    }

    #kill-feed-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        font-size: 20px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        background: #4a1e5a;
        color: #fff;
        border: 1px solid #7c3aed;
        border-radius: 50%;
    }
}

.kf-header {
    padding: 5px 10px;
    background: rgba(124, 58, 237, 0.2);
    border-bottom: 1px solid #444;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kf-status {
    font-size: 9px;
    color: #888;
}

.kf-status.live {
    color: #2ecc71;
    text-shadow: 0 0 5px #2ecc71;
}

.kf-body {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kf-body::-webkit-scrollbar {
    width: 4px;
}

.kf-body::-webkit-scrollbar-thumb {
    background: #444;
}

.kf-item {
    background: rgba(255, 255, 255, 0.03);
    border-left: 2px solid #555;
    padding: 4px 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.kf-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.kf-low {
    border-left-color: #95a5a6;
}

.kf-med {
    border-left-color: #f1c40f;
}

.kf-high {
    border-left-color: #e67e22;
}

.kf-ultra {
    border-left-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.kf-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.kf-sys {
    color: #58a6ff;
    font-weight: bold;
}

.kf-val {
    color: #eee;
}

.kf-ship {
    color: #aaa;
}

.kf-victim {
    color: #888;
}

.kill-float-text {
    font-family: 'Arial Black', sans-serif;
    font-weight: 900;
    font-size: 14px;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.1s;
    z-index: 200;
}

.kill-float-text.ultra {
    font-size: 18px;
    animation: text-shake 0.2s ease-in-out infinite;
}

@keyframes text-shake {
    0% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-1px, 1px);
    }

    50% {
        transform: translate(1px, -1px);
    }

    75% {
        transform: translate(-1px, -1px);
    }

    100% {
        transform: translate(0, 0);
    }
}
@media (max-width: 768px) {
    .region-label {
        font-size: 12px;
        text-shadow: 0 2px 5px #000;
    }
    .marker-label {
        font-size: 12px;
        top: -22px;
    }
}
