/*666666*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: white;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-tabs {
    display: flex;
    gap: 5px;
}

.nav-tab {
    padding: 8px 16px;
    border: none;
    background: #e8f4f8;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.nav-tab.active {
    background: #4a90e2;
    color: white;
}

.nav-tab:hover {
    background: #4a90e2;
    color: white;
}

.title {
    flex: 1;
    text-align: center;
    font-size: 24px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title::before {
    content: '4';
    background: #4a90e2;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.btn-next {
    padding: 8px 20px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.btn-next:hover {
    background: #357abd;
}

.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 180px;
    background: white;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid #e0e0e0;
}

.task-description {
    background: #e8f4f8;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    line-height: 1.6;
}

.materials {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    padding: 20px 0;
}

.btn-add-material {
    padding: 10px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.btn-add-material:hover {
    background: #357abd;
}

.canvas-container {
    flex: 1;
    background: #faf8f3;
    position: relative;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.footer {
    background: white;
    padding: 10px 20px;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

.toolbar {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.3s;
    font-size: 12px;
    color: #666;
}

.tool-btn:hover {
    background: #f0f0f0;
}

.tool-btn span:first-child {
    font-size: 24px;
}

.btn-delete:hover {
    background: #ffe6e6;
    color: #ff4444;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .container {
        padding: 0;
    }
    
    .header {
        flex-direction: column;
        gap: 8px;
        padding: 8px 10px;
    }
    
    .nav-tabs {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }
    
    .nav-tab {
        padding: 6px 10px;
        font-size: 12px;
        min-height: 36px;
    }
    
    .title {
        font-size: 18px;
        margin: 4px 0;
    }
    
    .btn-next {
        padding: 8px 16px;
        font-size: 14px;
        min-height: 40px;
    }
    
    .main-content {
        flex-direction: column;
        height: calc(100vh - 140px);
    }
    
    .sidebar {
        width: 100%;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
        min-height: auto;
        order: 2;
        max-height: 200px;
        overflow: hidden;
    }
    
    .task-description {
        width: 100%;
        text-align: center;
        font-size: 13px;
        padding: 4px;
        flex-shrink: 0;
    }
    
    .materials {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding: 8px 4px;
        flex: 1;
        touch-action: pan-x;
        position: relative;
        z-index: 1;
    }
    
    .material-item {
        min-width: 80px;
        max-width: 80px;
        min-height: 80px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px;
        border-radius: 8px;
        background: #f8f9fa;
        cursor: grab;
        user-select: none;
        -webkit-user-select: none;
        touch-action: pan-x pan-y;
        scroll-snap-align: start;
        flex-shrink: 0;
        border: 2px solid transparent;
        transition: all 0.2s;
        -webkit-touch-callout: none;
        position: relative;
        z-index: 1;
    }
    
    .material-item:active {
        transform: scale(0.95);
        background: #e9ecef;
        border-color: #4a90e2;
    }
    
    .material-item.dragging {
        opacity: 0.5;
        transform: scale(0.9);
    }
    
    .material-square {
        width: 32px;
        height: 32px;
        background: #4a90e2;
        border-radius: 4px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    
    .material-item span {
        font-size: 11px;
        color: #666;
    }
    
    .btn-add-material {
        width: 100%;
        padding: 10px;
        font-size: 14px;
        min-height: 40px;
        margin-top: 4px;
        flex-shrink: 0;
    }
    
    .canvas-container {
        height: calc(100vh - 280px);
        min-height: 300px;
        order: 1;
        margin: 8px;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    #gameCanvas {
        touch-action: none;
    }
    
    .footer {
        padding: 8px;
    }
    
    .toolbar {
        justify-content: space-around;
        gap: 4px;
    }
    
    .tool-btn {
        padding: 8px 12px;
        min-width: 60px;
        min-height: 44px;
        font-size: 12px;
        flex: 1;
        max-width: 80px;
    }
    
    .tool-btn span:first-child {
        font-size: 18px;
    }
}

/* 触摸拖拽反馈 */
.touch-dragging {
    opacity: 0.7;
    pointer-events: none;
}

.material-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

/* 禁用移动端双击缩放 */
* {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* 禁止文本选择 */
body {
    -webkit-user-select: none;
    user-select: none;
}

/* Canvas 允许触摸操作 */
#gameCanvas {
    touch-action: none;
}

.material-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    border: 2px solid transparent;
    transition: all 0.2s;
    min-width: 70px;
}

.material-item:hover {
    background: #e9ecef;
    border-color: #4a90e2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.material-item:active {
    cursor: grabbing;
}

.material-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.material-square {
    width: 40px;
    height: 40px;
    background: #4a90e2;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.material-item:hover .material-square {
    transform: scale(1.1);
}

.material-item span {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}
