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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
    color: #333;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* 头部 */
header {
    text-align: center;
    margin-bottom: 16px;
}

header h1 {
    font-size: 24px;
    color: #667eea;
}

/* 寄存器区 */
.registers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 12px;
}

.register {
    flex: 1;
    min-width: 80px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}

.register span {
    color: #667eea;
}

.register.pc {
    background: #fff3cd;
}

.register.changed {
    animation: highlight 0.5s;
}

@keyframes highlight {
    0%, 100% { background: #fff; }
    50% { background: #90EE90; }
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
    background: #28a745;
    color: white;
}

.btn-primary:hover {
    background: #218838;
}

.btn-secondary {
    background: #17a2b8;
    color: white;
}

.btn-secondary:hover {
    background: #138496;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* 代码区 */
.code-area {
    margin-bottom: 16px;
}

.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.area-header h2 {
    font-size: 16px;
    color: #667eea;
}

.drop-zone {
    min-height: 150px;
    padding: 12px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    position: relative;
}

.drop-zone.drag-over {
    border-color: #667eea;
    background: #e8f0fe;
}

.drop-zone .placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #adb5bd;
    pointer-events: none;
}

.drop-zone:not(:empty) .placeholder {
    display: none;
}

/* 指令区 */
.instruction-area {
    margin-bottom: 16px;
}

.instruction-area h2 {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 12px;
}

.instruction-pool {
    max-height: 250px;
    overflow-y: auto;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 12px;
}

.instruction-group {
    margin-bottom: 12px;
}

.group-title {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 6px;
    padding-left: 4px;
}

.instruction {
    padding: 10px 14px;
    margin: 4px 0;
    background: #fff;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: grab;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.instruction:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.instruction:active {
    cursor: grabbing;
}

.instruction.dragging {
    opacity: 0.5;
}

/* 代码区中的指令项 */
.code-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    margin: 6px 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.code-item .line-number {
    color: #adb5bd;
    margin-right: 10px;
    min-width: 24px;
    font-size: 12px;
}

.code-item .inst-name {
    color: #667eea;
    font-weight: bold;
    margin-right: 8px;
    min-width: 50px;
}

.code-item .operands {
    flex: 1;
    color: #333;
}

.code-item .operands input {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
}

.code-item .operands input:focus {
    outline: none;
    border-color: #667eea;
}

.code-item .remove-btn {
    margin-left: 8px;
    padding: 4px 8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.code-item.executing {
    background: #fff3cd;
    border: 2px solid #ffc107;
}

/* 输出区 */
.output-area {
    margin-bottom: 16px;
}

.output-area h2 {
    font-size: 16px;
    color: #667eea;
    margin-bottom: 8px;
}

.output-console {
    min-height: 80px;
    max-height: 150px;
    overflow-y: auto;
    padding: 12px;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.output-console .log-step {
    color: #4ec9b0;
}

.output-console .log-error {
    color: #f48771;
}

.output-console .log-info {
    color: #9cdcfe;
}

/* 状态栏 */
.status-bar {
    padding: 10px 14px;
    background: #e8f0fe;
    border-radius: 8px;
    font-size: 13px;
    color: #667eea;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-bar.error {
    background: #f8d7da;
    color: #721c24;
}

.status-bar.success {
    background: #d4edda;
    color: #155724;
}

/* 移动端优化 */
@media (max-width: 480px) {
    .container {
        padding: 12px;
        border-radius: 12px;
    }

    header h1 {
        font-size: 20px;
    }

    .register {
        font-size: 12px;
        padding: 6px 8px;
        min-width: 60px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 14px;
    }

    .code-item {
        font-size: 12px;
        padding: 8px 10px;
    }

    .code-item .operands input {
        width: 40px;
        font-size: 12px;
        padding: 3px 6px;
    }

    .drop-zone {
        min-height: 120px;
    }

    .instruction-pool {
        max-height: 200px;
    }

    .instruction {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* 滚动条样式 */
.instruction-pool::-webkit-scrollbar,
.output-console::-webkit-scrollbar {
    width: 6px;
}

.instruction-pool::-webkit-scrollbar-track,
.output-console::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.instruction-pool::-webkit-scrollbar-thumb,
.output-console::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.instruction-pool::-webkit-scrollbar-thumb:hover,
.output-console::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
