* { margin: 0; padding: 0; }
body {
    overflow: hidden;
    background: #05080f;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #fff;
    user-select: none;
}
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

.ui-overlay {
    position: fixed;
    z-index: 10;
    pointer-events: none;
}
.header-ui {
    top: 20px;
    left: 30px;
    pointer-events: auto;
}
.header-ui h1 {
    font-weight: 700;
    text-shadow: 0 0 40px rgba(255, 193, 7, 0.3);
    background: rgba(5, 8, 15, 0.8);
    backdrop-filter: blur(16px);
    padding: 12px 28px;
    border-radius: 20px;
    border: 1px solid rgba(255, 193, 7, 0.2);
    display: inline-block;
    font-size: 1.6rem;
    letter-spacing: -0.5px;
}
.header-ui h1 small {
    color: #ffc107;
    font-weight: 300;
    font-size: 1rem;
}

.btn-pause {
    pointer-events: auto;
    background: rgba(13, 110, 253, 0.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    padding: 8px 22px;
    border-radius: 40px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: inline-block;
    margin-left: 12px;
    cursor: pointer;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: 0.3px;
    outline: none;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.05);
}

.btn-pause:hover {
    background: rgba(255, 193, 7, 0.15);
    border-color: #ffc107;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 193, 7, 0.1);
}

.btn-pause:active {
    transform: scale(0.95);
}

.btn-pause.paused {
    background: rgba(0, 255, 136, 0.1);
    border-color: #00ff88;
    color: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.05);
}

.btn-pause.paused:hover {
    background: rgba(0, 255, 136, 0.15);
    border-color: #00ff88;
    color: #fff;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.1);
}

.history-panel {
    position: fixed;
    top: 90px;
    left: 30px;
    z-index: 15;
    background: rgba(5, 8, 15, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 193, 7, 0.15);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 220px;
    max-width: 300px;
    max-height: 60vh;
    overflow-y: auto;
    pointer-events: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
}
.history-panel::-webkit-scrollbar { width: 4px; }
.history-panel::-webkit-scrollbar-track { background: transparent; }
.history-panel::-webkit-scrollbar-thumb { background: #ffc10744; border-radius: 10px; }
.history-panel .panel-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6b7b98;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-panel .panel-title i { color: #ffc107; }

.history-accordion .accordion-item {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    margin-bottom: 2px;
}
.history-accordion .accordion-item:last-child { border-bottom: none; }
.history-accordion .accordion-header { background: transparent; padding: 0; }
.history-accordion .accordion-button {
    background: transparent;
    color: #b0c4e0;
    padding: 6px 8px;
    font-size: 0.75rem;
    border: none;
    box-shadow: none;
    border-radius: 8px;
    transition: 0.2s;
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-accordion .accordion-button:hover { background: rgba(255,255,255,0.03); }
.history-accordion .accordion-button .badge-count {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 12px;
}
.history-accordion .accordion-button .user-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.history-accordion .accordion-body { padding: 4px 8px 8px 8px; }
.history-accordion .accordion-body .history-item {
    padding: 4px 8px;
    font-size: 0.7rem;
    color: #8aa0c9;
    cursor: pointer;
    border-radius: 6px;
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 2px solid transparent;
}
.history-accordion .accordion-body .history-item:hover {
    background: rgba(255, 193, 7, 0.06);
    border-left-color: #ffc107;
    color: #fff;
}
.history-accordion .accordion-body .history-item .time { color: #4a5a7a; font-size: 0.6rem; }
.history-accordion .accordion-body .history-item .type-icon { margin-right: 6px; opacity: 0.6; }
.history-empty { color: #4a5a7a; font-size: 0.65rem; font-style: italic; padding: 4px 8px; }

.help-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 15;
    background: rgba(13, 110, 253, 0.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    padding: 10px 20px;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.3px;
    outline: none;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.05);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-btn:hover {
    background: rgba(255, 193, 7, 0.15);
    border-color: #ffc107;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 193, 7, 0.1);
}

.help-btn:active {
    transform: scale(0.95);
}

.help-btn i {
    font-size: 1.1rem;
}

.stats-ui {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 10;
    color: #8aa0c9;
    font-size: 0.8rem;
    background: rgba(5, 8, 15, 0.8);
    backdrop-filter: blur(12px);
    padding: 10px 20px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
}
.stats-ui span { color: #ffc107; font-weight: 600; }

.copyright-footer {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: #4a5a7a;
    font-size: 0.6rem;
    background: rgba(5, 8, 15, 0.6);
    backdrop-filter: blur(8px);
    padding: 6px 20px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    pointer-events: none;
    text-align: center;
    white-space: nowrap;
}

.copyright-footer p {
    margin: 0;
}

.copyright-footer .author-link {
    color: #6b7b98;
    text-decoration: none;
    transition: 0.3s;
}

.copyright-footer .author-link:hover {
    color: #ffc107;
}

.fps-counter {
    position: fixed;
    top: 20px;
    right: 30px;
    z-index: 10;
    color: #6b7b98;
    font-size: 0.7rem;
    background: rgba(5, 8, 15, 0.8);
    backdrop-filter: blur(12px);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
    font-family: monospace;
}
.fps-counter .fps-value {
    color: #00ff88;
    font-weight: 700;
    font-size: 0.9rem;
}
.fps-counter .fps-value.low { color: #ffaa00; }
.fps-counter .fps-value.critical { color: #ff4444; }

.tooltip-ui {
    position: fixed;
    z-index: 20;
    background: rgba(5, 8, 15, 0.92);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 193, 7, 0.3);
    padding: 10px 18px;
    border-radius: 12px;
    color: #fff;
    font-size: 0.8rem;
    pointer-events: none;
    display: none;
    max-width: 350px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.9);
}
.tooltip-ui .label { color: #ffc107; font-weight: 600; font-size: 0.9rem; }
.tooltip-ui .url { color: #8aa0c9; font-size: 0.65rem; word-break: break-all; margin-top: 4px; }
.tooltip-ui .type { color: #6b7b98; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.loading-ui {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    color: #ffc107;
    font-size: 1.2rem;
    background: rgba(5, 8, 15, 0.9);
    padding: 30px 50px;
    border-radius: 20px;
    border: 1px solid rgba(255, 193, 7, 0.2);
    backdrop-filter: blur(20px);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    transition: opacity 0.5s;
}
.loading-ui .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 193, 7, 0.1);
    border-top: 3px solid #ffc107;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-ui.hidden { opacity: 0; pointer-events: none; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 50;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}
.modal-overlay.active { display: flex; }
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.modal-content {
    background: rgba(5, 8, 15, 0.95);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 24px;
    padding: 40px 50px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 30px 80px rgba(0,0,0,0.9);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: #6b7b98;
    font-size: 1.8rem;
    cursor: pointer;
    transition: 0.3s;
}
.modal-content .close-btn:hover { color: #ffc107; transform: rotate(90deg); }
.modal-content .modal-icon { font-size: 3rem; margin-bottom: 10px; }
.modal-content h2 { color: #ffc107; font-weight: 700; font-size: 1.5rem; margin-bottom: 10px; }
.modal-content .modal-url { color: #8aa0c9; font-size: 0.8rem; word-break: break-all; margin-bottom: 15px; }
.modal-content .modal-desc { color: #b0c4e0; font-size: 0.95rem; line-height: 1.6; margin-bottom: 25px; }
.modal-content .modal-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.modal-content .modal-buttons .btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    transition: 0.3s;
    text-decoration: none;
    text-align: center;
}
.modal-content .modal-buttons .btn-primary {
    background: #0d6efd;
    border: 1px solid #0d6efd;
    color: #fff;
}
.modal-content .modal-buttons .btn-primary:hover { background: #0b5ed7; transform: scale(1.02); }
.modal-content .modal-buttons .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #b0c4e0;
}
.modal-content .modal-buttons .btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.modal-content .modal-type {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.2);
    color: #ffc107;
    margin-bottom: 12px;
}

.help-modal-content {
    max-width: 550px;
    padding: 30px 35px;
}

.help-modal-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 10px;
}

.help-modal-title {
    text-align: center;
    color: #ffc107 !important;
    font-weight: 700;
    font-size: 1.3rem !important;
    margin-bottom: 20px !important;
}

.help-modal-body {
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 5px;
}

.help-modal-body::-webkit-scrollbar { width: 4px; }
.help-modal-body::-webkit-scrollbar-track { background: transparent; }
.help-modal-body::-webkit-scrollbar-thumb { background: #ffc10744; border-radius: 10px; }

.help-section {
    margin-bottom: 12px;
}

.help-section-title {
    color: #8aa0c9;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 700;
}

.help-legend-item {
    display: flex;
    align-items: center;
    padding: 4px 0;
    font-size: 0.75rem;
    color: #b0c4e0;
}

.help-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.help-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.7rem;
    color: #b0c4e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.help-key {
    color: #ffc107;
    font-weight: 600;
    font-size: 0.65rem;
    background: rgba(255, 193, 7, 0.08);
    padding: 2px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.help-desc {
    color: #8aa0c9;
    font-size: 0.65rem;
    text-align: right;
    margin-left: 12px;
}

.help-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 8px 0;
}

.help-modal-footer {
    margin-top: 20px;
    text-align: center;
}

.help-modal-footer .btn {
    padding: 8px 40px;
    border-radius: 30px;
    font-weight: 600;
    background: #0d6efd;
    border: 1px solid #0d6efd;
    color: #fff;
    transition: 0.3s;
}

.help-modal-footer .btn:hover {
    background: #0b5ed7;
    transform: scale(1.02);
}

.modal-type.traveler {
    color: #ffc107;
    border-color: #ffc107;
}

@media (min-width: 769px) {
    .help-btn {
        bottom: 30px;
        right: 30px;
    }

    .copyright-footer {
        bottom: 30px;
    }

    .stats-ui {
        bottom: 30px;
        left: 30px;
    }
}

@media (max-width: 768px) {
    .header-ui {
        top: 10px;
        left: 10px;
        right: 10px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .header-ui h1 {
        font-size: 1rem;
        padding: 8px 14px;
        width: 100%;
        text-align: center;
    }

    .header-ui h1 small {
        font-size: 0.7rem;
    }

    .btn-pause {
        font-size: 0.75rem;
        padding: 6px 16px;
        margin-left: 0;
        width: 100%;
        text-align: center;
    }

    .history-panel {
        top: auto;
        bottom: 80px;
        left: 10px;
        right: 10px;
        min-width: unset;
        max-width: unset;
        max-height: 35vh;
        padding: 10px 12px;
        border-radius: 12px;
    }

    .history-panel .panel-title {
        font-size: 0.6rem;
    }

    .history-accordion .accordion-button {
        font-size: 0.65rem;
        padding: 4px 6px;
    }

    .history-accordion .accordion-body .history-item {
        font-size: 0.6rem;
        padding: 3px 6px;
    }

    .stats-ui {
        font-size: 0.6rem;
        padding: 6px 12px;
        bottom: 15px;
        left: 15px;
        right: 15px;
        text-align: center;
    }

    .copyright-footer {
        bottom: 65px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.5rem;
        padding: 4px 14px;
        white-space: nowrap;
        z-index: 12;
    }

    .help-btn {
        bottom: 15px;
        right: 15px;
        font-size: 0.7rem;
        padding: 8px 16px;
        z-index: 12;
    }

    .fps-counter {
        font-size: 0.6rem;
        padding: 4px 10px;
        top: 10px;
        right: 10px;
    }

    .loading-ui {
        padding: 20px 30px;
        font-size: 1rem;
    }

    .modal-content {
        padding: 25px 20px;
        margin: 10px;
        max-width: 95%;
        max-height: 95vh;
    }

    .modal-content .modal-icon {
        font-size: 2rem;
    }

    .modal-content h2 {
        font-size: 1.2rem;
    }

    .modal-content .modal-buttons .btn {
        min-width: 80px;
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    .help-modal-content {
        padding: 20px 16px;
        max-width: 100%;
    }

    .help-modal-title {
        font-size: 1.1rem !important;
    }

    .help-legend-item {
        font-size: 0.7rem;
    }

    .help-item {
        font-size: 0.6rem;
    }

    .help-key {
        font-size: 0.55rem;
        padding: 2px 6px;
    }

    .help-desc {
        font-size: 0.55rem;
    }

    .help-modal-body {
        max-height: 45vh;
    }
}

@media (max-width: 480px) {
    .header-ui h1 {
        font-size: 0.85rem;
        padding: 6px 10px;
    }

    .btn-pause {
        font-size: 0.65rem;
        padding: 5px 12px;
    }

    .history-panel {
        max-height: 30vh;
        bottom: 70px;
        padding: 8px 10px;
    }

    .stats-ui {
        font-size: 0.5rem;
        padding: 4px 10px;
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .copyright-footer {
        bottom: 55px;
        font-size: 0.45rem;
        padding: 3px 10px;
        white-space: nowrap;
    }

    .fps-counter {
        font-size: 0.5rem;
        padding: 3px 8px;
        top: 8px;
        right: 8px;
    }

    .help-btn {
        bottom: 12px;
        right: 12px;
        font-size: 0.6rem;
        padding: 6px 12px;
    }

    .help-btn i {
        font-size: 0.8rem;
    }

    .help-modal-content {
        padding: 15px 12px;
    }

    .help-modal-title {
        font-size: 1rem !important;
    }

    .help-modal-body {
        max-height: 40vh;
    }
}

@media (max-width: 380px) {
    .copyright-footer {
        bottom: 48px;
        font-size: 0.4rem;
        padding: 2px 8px;
    }

    .help-btn {
        bottom: 10px;
        right: 10px;
        font-size: 0.55rem;
        padding: 5px 10px;
    }

    .history-panel {
        bottom: 60px;
        max-height: 25vh;
    }
}