* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: #000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    touch-action: none;
}

#canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: none;
}

#controls {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border-radius: 15px;
    color: white;
    z-index: 1001;
    max-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
    transition: opacity 0.3s;
    border: 2px solid #ff3333;
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.5);
}

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

h2 {
    margin-bottom: 15px;
    font-size: 24px;
    text-align: center;
    color: #ff3333;
    text-shadow: 0 0 10px rgba(255, 51, 51, 0.8);
}

.version {
    text-align: center;
    font-size: 11px;
    color: #666;
    margin-top: -10px;
    margin-bottom: 15px;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

button {
    background: linear-gradient(135deg, #ff3333, #cc0000);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 16px;
    margin: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

button:active {
    background: #cc0000;
    transform: translateY(0);
}

button:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.button-group {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    display: block;
    margin: 15px 0 5px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

label input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
    transform: scale(1.2);
}

select,
input[type="range"] {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
    background: #222;
    color: white;
    font-size: 14px;
    transition: border-color 0.3s;
}

select:focus,
input[type="range"]:focus {
    outline: none;
    border-color: #ff3333;
}

input[type="range"] {
    padding: 0;
    height: 35px;
}

.info {
    font-size: 12px;
    color: #888;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #333;
    text-align: center;
}

.background-capture-section {
    margin: 15px 0;
    padding: 15px;
    background: rgba(255, 107, 0, 0.1);
    border-radius: 10px;
    border: 1px solid #ff6b00;
}

.background-capture-section label {
    color: #ff6b00;
    font-weight: bold;
    margin-bottom: 10px;
}

#video {
    display: none;
}

.status {
    background: #1a1a1a;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    font-size: 12px;
    border-left: 3px solid #666;
    transition: all 0.3s;
}

.status.active {
    background: #002200;
    color: #00ff00;
    border-left-color: #00ff00;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.value-display {
    display: inline-block;
    min-width: 40px;
    text-align: right;
    color: #ff3333;
    font-weight: bold;
}

/* Terminal Modal */
.terminal-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.terminal-modal.active {
    display: flex;
    pointer-events: auto;
}

.terminal-window {
    background: #0a0a0a;
    border: 2px solid #0f0;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 255, 0, 0.5);
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    background: #1a1a1a;
    border-bottom: 1px solid #0f0;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Courier New', monospace;
    color: #0f0;
    font-weight: bold;
}

.terminal-close {
    background: #ff3333;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.terminal-close:hover {
    background: #ff0000;
    transform: scale(1.1);
}

.terminal-log {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #000;
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.terminal-log::-webkit-scrollbar {
    width: 10px;
}

.terminal-log::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.terminal-log::-webkit-scrollbar-thumb {
    background: #0f0;
    border-radius: 5px;
}

.terminal-footer {
    background: #1a1a1a;
    border-top: 1px solid #0f0;
    padding: 10px 15px;
    display: flex;
    gap: 10px;
}

.terminal-footer button {
    flex: 1;
    background: linear-gradient(135deg, #0f0, #0a0);
    color: #000;
    font-weight: bold;
}

.terminal-footer button:hover {
    background: linear-gradient(135deg, #0a0, #080);
}

/* Debug Minimap */
.minimap {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 10px;
    z-index: 1002;
    display: none;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.minimap.visible {
    display: block;
}

.minimap-header {
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.8);
}

#minimapCanvas {
    width: 100%;
    height: auto;
    border: 1px solid #0a0;
    border-radius: 5px;
    background: #000;
    display: block;
}

.minimap-info {
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    margin-top: 8px;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #666;
    border-top-color: #ff3333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive design for mobile */
@media (max-width: 480px) {
    #controls {
        max-width: 90%;
        left: 5%;
        top: 10px;
        padding: 15px;
    }

    h2 {
        font-size: 20px;
    }

    button {
        padding: 12px 20px;
        font-size: 14px;
    }

    .minimap {
        width: 90%;
        left: 5%;
        right: auto;
        bottom: 10px;
    }
}
