/* --- 全局样式 & 赛博朋克主题 --- */
:root {
    --neon-cyan: #00f3ff;
    --neon-pink: #ff00ff;
    --neon-yellow: #faff00;
    --bg-color: #000000;
    --panel-bg: rgba(0, 10, 20, 0.4);
    --border-color: rgba(0, 243, 255, 0.3);
    --font-main: 'Courier New', Courier, monospace;
}

body {
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: var(--font-main);
    color: var(--neon-cyan);
    user-select: none;
    -webkit-user-select: none;
}

canvas { display: block; }

/* --- UI 组件 --- */
/* 顶部状态栏 */
#top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    z-index: 10;
    pointer-events: none;
    text-shadow: 0 0 5px var(--neon-cyan);
}

/* 右侧悬浮面板 (Glassmorphism) */
#control-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 220px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 2px solid var(--neon-pink);
    border-radius: 12px;
    z-index: 20;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.3s ease;
}

.panel-title {
    font-size: 14px;
    color: var(--neon-pink);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
}

.grid-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 15px;
}

button {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--border-color);
    color: var(--neon-cyan);
    padding: 8px;
    font-family: var(--font-main);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

button:hover, button.active {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 10px var(--neon-cyan);
}

.input-group {
    margin-top: 10px;
    display: flex;
    gap: 5px;
}

input[type="text"] {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    color: white;
    padding: 5px;
    font-family: var(--font-main);
    font-size: 10px;
}

/* 摄像头预览 (左下角) */
#cam-preview-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 160px;
    height: 120px;
    border: 1px solid var(--neon-cyan);
    z-index: 10;
    overflow: hidden;
    background: #000;
}

#cam-canvas {
    width: 100%;
    height: 100%;
    filter: contrast(1.2) saturate(0) sepia(1) hue-rotate(130deg); /* Cyberpunk Green tint */
    opacity: 0.8;
}

#cam-overlay {
    position: absolute;
    bottom: 2px;
    left: 5px;
    font-size: 10px;
    color: var(--neon-cyan);
    background: rgba(0,0,0,0.7);
    padding: 2px 4px;
}

/* 视觉准星 */
#cursor {
    position: absolute;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 100;
    transition: width 0.2s, height 0.2s, border-color 0.2s;
    display: none; /* Hidden until hand detected */
}

/* 准星状态：捏合 (Pinch) - 实心黄点 */
.cursor-pinch {
    width: 16px;
    height: 16px;
    background-color: var(--neon-yellow);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon-yellow);
}

/* 准星状态：张开 (Open) - 旋转蓝色虚线圈 */
.cursor-open {
    width: 60px;
    height: 60px;
    border: 2px dashed var(--neon-cyan);
    border-radius: 50%;
    background: transparent;
    animation: spin 2s linear infinite;
}

/* 准星状态：悬停 (Hover) - 小十字/方框 */
.cursor-hover {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

@keyframes spin { 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* 错误提示 */
#error-modal {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 0, 0, 0.9);
    border: 2px solid red;
    padding: 20px;
    text-align: center;
    color: red;
    display: none;
    z-index: 1000;
}

/* 隐藏原始视频元素 */
#webcam { display: none; }