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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #333;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

h1 {
    color: #2c3e50;
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.connection-panel {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-info label {
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.connection-info input {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    min-width: 200px;
}

.connection-info input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

.btn-secondary {
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.4);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: #6c757d;
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.status {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    background: #e0e0e0;
    color: #666;
}

.status.connected {
    background: #28a745;
    color: white;
}

.status.connecting {
    background: #ffc107;
    color: #212529;
}

main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.movement-control, .function-control, .status-panel, .log-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.movement-control h3, .function-control h3, .status-panel h3, .log-panel h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.4em;
    text-align: center;
}

.movement-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 300px;
    margin: 0 auto;
}

.movement-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: center;
}

.empty-cell {
    height: 80px;
}

.center-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 80px;
}

.center-dot {
    width: 20px;
    height: 20px;
    background: #6c757d;
    border-radius: 50%;
    margin-bottom: 5px;
}

.center-indicator span {
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border: 3px solid #e9ecef;
    border-radius: 12px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
    font-weight: 600;
}

.movement-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.function-btn {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    border-color: #f093fb;
    min-height: 100px;
    margin-bottom: 15px;
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.control-btn:active, .control-btn.active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.btn-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.btn-text {
    font-size: 14px;
    font-weight: 700;
}

.btn-channel {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 3px;
}

.function-buttons {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.dual-control {
    text-align: center;
}

.dual-control label {
    display: block;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.dual-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.status-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-item label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.channel-value {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
}

.channel-bar {
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.channel-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 50%;
}

.log-container {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.log-entry {
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 13px;
    color: #495057;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.command {
    color: #007bff;
    font-weight: 600;
}

.log-entry.error {
    color: #dc3545;
    font-weight: 600;
}

.log-entry.success {
    color: #28a745;
    font-weight: 600;
}

.touch-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 1000;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    .connection-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .connection-info {
        flex-direction: column;
        align-items: stretch;
    }
    
    .connection-info input {
        min-width: auto;
    }
    
    .movement-grid {
        max-width: 250px;
    }
    
    .control-btn {
        min-height: 70px;
    }
    
    .btn-icon {
        font-size: 20px;
    }
    
    .btn-text {
        font-size: 12px;
    }
}

/* 滚动条样式 */
.log-container::-webkit-scrollbar {
    width: 6px;
}

.log-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.log-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 动画效果 */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.control-btn.pulse {
    animation: pulse 0.3s ease;
}