:root {
    --primary: #76b900;
    --primary-light: #4a7300;
    --secondary: #8bc400;
    --accent: #ff6e6e;
    --bg: #1a1a1a;
    --surface: #2c2c2c;
    --text: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border: #444444;
    --shadow: rgba(0, 0, 0, 0.2);
    --shadow-hover: rgba(0, 0, 0, 0.3);
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

#canvas-container {
    position: absolute;
    width: 100%;
    height: 100%;
}

#ui-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

#status-bar {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(30, 30, 30, 0.9);
    padding: 8px 16px;
    border-radius: 8px;
    pointer-events: auto;
    box-shadow: 0 4px 6px var(--shadow);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    color: var(--text);
    transition: opacity 0.5s ease, transform 0.5s ease;
    font-weight: 500;
}

#status-bar.hidden {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

#control-panel {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 44, 44, 0.95);
    padding: 6px 8px;
    border-radius: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    pointer-events: auto;
    box-shadow: 0 4px 10px var(--shadow);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
}

#timeline {
    width: 150px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

#progress {
    position: absolute;
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    width: 0%;
}

#playback-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

button,
select,
input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    font: 500 6px 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

button:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(118, 185, 0, 0.4);
}

.icon {
    width: 10px;
    height: 10px;
    fill: currentColor;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text);
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 7px;
    white-space: nowrap;
    margin-bottom: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    box-shadow: 0 2px 4px var(--shadow);
    border: 1px solid var(--border);
}

button:hover .tooltip {
    opacity: 1;
}

#settings-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(44, 44, 44, 0.98);
    padding: 10px;
    border-radius: 6px;
    width: 195px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    pointer-events: auto;
    box-shadow: 0 4px 15px var(--shadow);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
    transition: transform 0.35s ease-in-out, opacity 0.3s ease-in-out;
}

#settings-panel.is-hidden {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
}

#settings-panel::-webkit-scrollbar {
    width: 3px;
}

#settings-panel::-webkit-scrollbar-track {
    background: transparent;
}

#settings-panel::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 3px;
}

@media (max-width: 768px) {
    #control-panel {
        width: 90%;
        flex-wrap: wrap;
        justify-content: center;
    }

    #timeline {
        width: 100%;
        order: 3;
        margin-top: 10px;
    }

    #settings-panel {
        width: 140px;
        right: 10px;
        top: 10px;
        max-height: calc(100vh - 20px);
    }
}

.settings-group {
    margin-bottom: 8px;
}

.settings-group h3 {
    margin: 0 0 6px 0;
    font: 500 10px 'Inter';
    color: var(--text-secondary);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.slider-container label {
    min-width: 60px;
    font-size: 10px;
    flex-shrink: 0;
}

input[type="range"] {
    flex: 1;
    height: 2px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
    min-width: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 10px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 10px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 8px;
    width: 8px;
    left: 1px;
    bottom: 1px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: .4s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background: var(--primary);
}

input:checked+.toggle-slider:before {
    transform: translateX(10px);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.checkbox-container label {
    font-size: 10px;
    cursor: pointer;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s;
}

#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(118, 185, 0, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

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

#loading-text {
    margin-top: 16px;
    font-size: 18px;
    color: var(--text);
    font-weight: 500;
}

#frame-counter {
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
    padding: 0 4px;
}

.control-btn {
    font-size: 10px;
}

.control-btn.active:hover {
    box-shadow: 0 2px 8px rgba(118, 185, 0, 0.4);
}

#settings-toggle-btn {
    position: relative;
    border-radius: 6px;
    z-index: 20;
}

#status-bar,
#control-panel,
#settings-panel,
button,
input,
select,
.toggle-switch {
    pointer-events: auto;
}

h2 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--primary);
    cursor: move;
    user-select: none;
    display: flex;
    align-items: center;
}

.drag-handle {
    font-size: 10px;
    margin-right: 4px;
    opacity: 0.6;
}

h2:hover .drag-handle {
    opacity: 1;
}

.loading-subtitle {
    font-size: 7px;
    color: var(--text-secondary);
    margin-top: 4px;
}

#reset-view-btn,
#reset-settings-btn {
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid rgba(118, 185, 0, 0.2);
    font: 600 9px 'Inter';
    padding: 4px 6px;
    transition: all 0.2s;
}

#reset-view-btn:hover,
#reset-settings-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(118, 185, 0, 0.3);
}

#show-settings-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 15;
    display: none;
}

#settings-panel.visible {
    display: block;
    opacity: 1;
    animation: slideIn 0.3s ease forwards;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.dragging {
    opacity: 0.9;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
    transition: none !important;
}

.tooltip-drag {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    white-space: nowrap;
    bottom: 100%;
    margin-bottom: 4px;
}

h2:hover .tooltip-drag {
    opacity: 1;
}

.btn-group {
    display: flex;
    margin-top: 8px;
}